[PATCH] drm/radeon: fix bo creation retry path

Michel Dänzer michel at daenzer.net
Tue Aug 21 00:03:46 PDT 2012


On Fre, 2012-07-13 at 07:54 +0200, Michel Dänzer wrote: 
> On Don, 2012-07-12 at 18:23 -0400, j.glisse at gmail.com wrote: 
> > From: Jerome Glisse <jglisse at redhat.com>
> > 
> > Retry label was at wrong place in function leading to memory
> > leak.
> > 
> > Cc: <stable at vger.kernel.org>
> > Signed-off-by: Jerome Glisse <jglisse at redhat.com>
> > ---
> >  drivers/gpu/drm/radeon/radeon_object.c |    3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
> > index 6ecb200..f71e472 100644
> > --- a/drivers/gpu/drm/radeon/radeon_object.c
> > +++ b/drivers/gpu/drm/radeon/radeon_object.c
> > @@ -138,7 +138,6 @@ int radeon_bo_create(struct radeon_device *rdev,
> >  	acc_size = ttm_bo_dma_acc_size(&rdev->mman.bdev, size,
> >  				       sizeof(struct radeon_bo));
> >  
> > -retry:
> >  	bo = kzalloc(sizeof(struct radeon_bo), GFP_KERNEL);
> >  	if (bo == NULL)
> >  		return -ENOMEM;
> > @@ -152,6 +151,8 @@ retry:
> >  	bo->surface_reg = -1;
> >  	INIT_LIST_HEAD(&bo->list);
> >  	INIT_LIST_HEAD(&bo->va);
> > +
> > +retry:
> >  	radeon_ttm_placement_from_domain(bo, domain);
> >  	/* Kernel allocation are uninterruptible */
> >  	down_read(&rdev->pm.mclk_lock);
> 
> Reviewed-by: Michel Dänzer <michel.daenzer at amd.com>

Actually, this is wrong: ttm_bo_init() destroys the BO on failure. So
this patch makes the retry path work with freed memory. I see on IRC
that this is causing panics with some piglit tests for several people,
please submit a patch to revert this.

Sorry I didn't remember this when reviewing the patch. :(


-- 
Earthling Michel Dänzer           |                   http://www.amd.com
Libre software enthusiast         |          Debian, X and DRI developer


More information about the dri-devel mailing list