From: Matthew Auld Date: Fri, 2 Jul 2021 10:46:42 +0000 (+0100) Subject: drm/i915/selftests: fix smatch warning in mock_reserve X-Git-Tag: v5.15~303^2~16^2~191 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b23228f287bc7dd970fed85f15ea4630b93fc8a0;p=platform%2Fkernel%2Flinux-starfive.git 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 --- diff --git a/drivers/gpu/drm/i915/selftests/intel_memory_region.c b/drivers/gpu/drm/i915/selftests/intel_memory_region.c index 1aaccb9841a0..418caae84759 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; }