From: Marcin Slusarz Date: Mon, 22 Aug 2011 21:14:05 +0000 (+0200) Subject: drm/nouveau: properly handle allocation failure in nouveau_sgdma_populate X-Git-Tag: v3.0.5~166 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=045451f9de4d9b7a7a961bf2428b990edf543271;p=karo-tx-linux.git drm/nouveau: properly handle allocation failure in nouveau_sgdma_populate commit 17c8b960930da3599e47801a54ac0ea1070545d2 upstream. 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 Signed-off-by: Ben Skeggs Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c index 82fad914e648..ca6028f24b80 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--) {