Marcin Slusarz
2011-Aug-22 21:14 UTC
[Nouveau] [PATCH] drm/nouveau: properly handle allocation failure in nouveau_sgdma_populate
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 <marcin.slusarz at gmail.com> Cc: stable at kernel.org --- 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
Konrad Rzeszutek Wilk
2011-Aug-23 02:52 UTC
[Nouveau] [PATCH] drm/nouveau: properly handle allocation failure in nouveau_sgdma_populate
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 <marcin.slusarz at gmail.com> > Cc: stable at kernel.orgAcked-by: Konrad Rzeszutek Wilk <konrad.wilk at oracle.com>> --- > 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 at lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/nouveau