Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 46a79fa0 authored by Dan Carpenter's avatar Dan Carpenter Committed by Dave Airlie
Browse files

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: default avatarDan Carpenter <error27@gmail.com>
Acked-By: default avatarThomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 1a95916f
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -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;