From: Dan Carpenter Date: Sat, 28 Nov 2009 10:30:32 +0000 (+0200) Subject: drm/ttm: fix small memory leak in ttm_memory.c X-Git-Tag: firefly_0821_release~9833^2~3227^2~87^2~11 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=46a79fa08a9a890a12cf9ec3ce51800911a907bf;p=firefly-linux-kernel-4.4.55.git drm/ttm: fix small memory leak in ttm_memory.c I moved the allocation until after the check for (si->totalhigh == 0). Signed-off-by: Dan Carpenter Acked-By: Thomas Hellstrom Signed-off-by: Dave Airlie --- diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c index 072c281a6bb5..336976e8652d 100644 --- a/drivers/gpu/drm/ttm/ttm_memory.c +++ b/drivers/gpu/drm/ttm/ttm_memory.c @@ -274,16 +274,17 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob, static int ttm_mem_init_highmem_zone(struct ttm_mem_global *glob, const struct sysinfo *si) { - struct ttm_mem_zone *zone = kzalloc(sizeof(*zone), GFP_KERNEL); + struct ttm_mem_zone *zone; uint64_t mem; int ret; - if (unlikely(!zone)) - return -ENOMEM; - if (si->totalhigh == 0) return 0; + zone = kzalloc(sizeof(*zone), GFP_KERNEL); + if (unlikely(!zone)) + return -ENOMEM; + mem = si->totalram; mem *= si->mem_unit;