From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: Re: [PATCH] drm/nouveau: properly handle allocation failure in nouveau_sgdma_populate Date: Mon, 22 Aug 2011 22:52:51 -0400 Message-ID: <20110823025251.GB24557@dumpdata.com> References: <20110822211405.GA3098@joi.lan> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20110822211405.GA3098-OI9uyE9O0yo@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: nouveau-bounces+gcfxn-nouveau=m.gmane.org-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Errors-To: nouveau-bounces+gcfxn-nouveau=m.gmane.org-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org To: Marcin Slusarz Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org List-Id: nouveau.vger.kernel.org On Mon, Aug 22, 2011 at 11:14:05PM +0200, Marcin Slusarz wrote: > Not cleaning after alloc failure would result in crash on destroy, > because nouveau_sgdma_clear assumes "ttm_alloced" to be not null when > "pages" is not null. > > Signed-off-by: Marcin Slusarz > Cc: stable-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org Acked-by: Konrad Rzeszutek Wilk > --- > drivers/gpu/drm/nouveau/nouveau_sgdma.c | 5 ++++- > 1 files changed, 4 insertions(+), 1 deletions(-) > > diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c > index 82fad91..ca6028f 100644 > --- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c > +++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c > @@ -37,8 +37,11 @@ nouveau_sgdma_populate(struct ttm_backend *be, unsigned long num_pages, > return -ENOMEM; > > nvbe->ttm_alloced = kmalloc(sizeof(bool) * num_pages, GFP_KERNEL); > - if (!nvbe->ttm_alloced) > + if (!nvbe->ttm_alloced) { > + kfree(nvbe->pages); > + nvbe->pages = NULL; > return -ENOMEM; > + } > > nvbe->nr_pages = 0; > while (num_pages--) { > -- > 1.7.6 > > _______________________________________________ > Nouveau mailing list > Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org > http://lists.freedesktop.org/mailman/listinfo/nouveau