drm/nouveau: properly handle allocation failure in nouveau_sgdma_populate
Subsystems (3)
PATCH 1/1 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 <[email protected]>
--- drivers/gpu/drm/nouveau/nouveau_sgdma.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/gpu/drm/nouveau/nouveau_sgdma.c +4 -1
@@ -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--) {
Signature · 1 line
1.7.6
A message that is not in the archive (sent off-list or not yet received): [email protected]
Konrad Rzeszutek Wilk
Acked-byQuoted 6 lines · Marcin Slusarz
Not cleaning after alloc failure would result in crash on destroy, because
nouveau_sgdma_clearassumes "ttm_alloced" to be not null when "pages" is not null.Signed-off-by Marcin Slusarz <[email protected]>
Quoted 28 lines
--- drivers/gpu/drm/nouveau/nouveau_sgdma.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)drivers/gpu/drm/nouveau/nouveau_sgdma.c +4
-1@@ -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--) {Signature · 6 lines
1.7.6 _______________________________________________ Nouveau mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/nouveau