diff options
author | Dan Carpenter <error27@gmail.com> | 2009-11-28 05:30:32 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2009-12-03 18:03:33 -0500 |
commit | 46a79fa08a9a890a12cf9ec3ce51800911a907bf (patch) | |
tree | f3d992722fae66bfcd7a27239a3e3758bfcb6d60 /drivers/gpu | |
parent | 1a95916f5465ad6c91398f17924949db7e0b5c36 (diff) |
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 <error27@gmail.com>
Acked-By: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_memory.c | 9 |
1 files changed, 5 insertions, 4 deletions
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, | |||
274 | static int ttm_mem_init_highmem_zone(struct ttm_mem_global *glob, | 274 | static int ttm_mem_init_highmem_zone(struct ttm_mem_global *glob, |
275 | const struct sysinfo *si) | 275 | const struct sysinfo *si) |
276 | { | 276 | { |
277 | struct ttm_mem_zone *zone = kzalloc(sizeof(*zone), GFP_KERNEL); | 277 | struct ttm_mem_zone *zone; |
278 | uint64_t mem; | 278 | uint64_t mem; |
279 | int ret; | 279 | int ret; |
280 | 280 | ||
281 | if (unlikely(!zone)) | ||
282 | return -ENOMEM; | ||
283 | |||
284 | if (si->totalhigh == 0) | 281 | if (si->totalhigh == 0) |
285 | return 0; | 282 | return 0; |
286 | 283 | ||
284 | zone = kzalloc(sizeof(*zone), GFP_KERNEL); | ||
285 | if (unlikely(!zone)) | ||
286 | return -ENOMEM; | ||
287 | |||
287 | mem = si->totalram; | 288 | mem = si->totalram; |
288 | mem *= si->mem_unit; | 289 | mem *= si->mem_unit; |
289 | 290 | ||