diff options
author | Marcin Slusarz <marcin.slusarz@gmail.com> | 2011-08-22 17:14:05 -0400 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2011-09-09 03:24:06 -0400 |
commit | 17c8b960930da3599e47801a54ac0ea1070545d2 (patch) | |
tree | e0822fc2fb25b39e2b4fc957615a76ce0cdae0ed | |
parent | cfd8be088e97a762902a4820f501fb13102984e9 (diff) |
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@gmail.com>
Cc: stable@kernel.org
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r-- | 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 c444cadbf849..88062de26b00 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, | |||
37 | return -ENOMEM; | 37 | return -ENOMEM; |
38 | 38 | ||
39 | nvbe->ttm_alloced = kmalloc(sizeof(bool) * num_pages, GFP_KERNEL); | 39 | nvbe->ttm_alloced = kmalloc(sizeof(bool) * num_pages, GFP_KERNEL); |
40 | if (!nvbe->ttm_alloced) | 40 | if (!nvbe->ttm_alloced) { |
41 | kfree(nvbe->pages); | ||
42 | nvbe->pages = NULL; | ||
41 | return -ENOMEM; | 43 | return -ENOMEM; |
44 | } | ||
42 | 45 | ||
43 | nvbe->nr_pages = 0; | 46 | nvbe->nr_pages = 0; |
44 | while (num_pages--) { | 47 | while (num_pages--) { |