From b23228f287bc7dd970fed85f15ea4630b93fc8a0 Mon Sep 17 00:00:00 2001 From: Matthew Auld Date: Fri, 2 Jul 2021 11:46:42 +0100 Subject: [PATCH] drm/i915/selftests: fix smatch warning in mock_reserve If mock_region_create fails then mem will be an error pointer. Instead we just need to use the correct ordering for the onion unwind. igt_mock_reserve() error: 'mem' dereferencing possible ERR_PTR() Reported-by: kernel test robot Reported-by: Dan Carpenter Signed-off-by: Matthew Auld Reviewed-by: Ramalingam C Link: https://patchwork.freedesktop.org/patch/msgid/20210702104642.1189978-2-matthew.auld@intel.com --- drivers/gpu/drm/i915/selftests/intel_memory_region.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/selftests/intel_memory_region.c b/drivers/gpu/drm/i915/selftests/intel_memory_region.c index 1aaccb9841a08..418caae847597 100644 --- a/drivers/gpu/drm/i915/selftests/intel_memory_region.c +++ b/drivers/gpu/drm/i915/selftests/intel_memory_region.c @@ -173,7 +173,7 @@ static int igt_mock_reserve(void *arg) if (IS_ERR(mem)) { pr_err("failed to create memory region\n"); err = PTR_ERR(mem); - goto out_close; + goto out_free_order; } /* Reserve a bunch of ranges within the region */ @@ -224,9 +224,10 @@ static int igt_mock_reserve(void *arg) } out_close: - kfree(order); close_objects(mem, &objects); intel_memory_region_put(mem); +out_free_order: + kfree(order); return err; } -- 2.39.5