diff mbox series

[2/2] drm/i915/selftests: fix smatch warning in mock_reserve

Message ID 20210702104642.1189978-2-matthew.auld@intel.com (mailing list archive)
State New, archived
Headers show
Series [1/2] drm/i915/selftests: fix smatch warning in igt_check_blocks | expand

Commit Message

Matthew Auld July 2, 2021, 10:46 a.m. UTC
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 <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
---
 drivers/gpu/drm/i915/selftests/intel_memory_region.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Ramalingam C July 6, 2021, 9:43 a.m. UTC | #1
On 2021-07-02 at 11:46:42 +0100, Matthew Auld wrote:
> 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 <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Matthew Auld <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 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);
LGTM.

Reviewed-by: Ramalingam C <ramalingam.c@intel.com>
>  	return err;
>  }
>  
> -- 
> 2.26.3
>
diff mbox series

Patch

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;
 }