Skip to content

Commit

Permalink
drm/nouveau: properly handle allocation failure in nouveau_sgdma_popu…
Browse files Browse the repository at this point in the history
…late

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@gmail.com>
Cc: stable@kernel.org
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
  • Loading branch information
Marcin Slusarz authored and Ben Skeggs committed Sep 9, 2011
1 parent cfd8be0 commit 17c8b96
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/gpu/drm/nouveau/nouveau_sgdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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--) {
Expand Down

0 comments on commit 17c8b96

Please sign in to comment.