mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/xe/selftests: Fix an error pointer dereference bug
@ 2024-01-05 12:20 Dan Carpenter
  2024-01-05 20:25 ` Matthew Brost
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2024-01-05 12:20 UTC (permalink / raw)
  To: Himal Prasad Ghimiray
  Cc: Lucas De Marchi, Oded Gabbay, Thomas Hellström,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rodrigo Vivi, Matthew Auld,
	Nirmoy Das, Matt Roper, Matthew Brost, Pallavi Mishra, intel-xe,
	dri-devel, linux-kernel, kernel-janitors

Check if "bo" is an error pointer before calling xe_bo_lock() on it.

Fixes: d6abc18d6693 ("drm/xe/xe2: Modify xe_bo_test for system memory")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/gpu/drm/xe/tests/xe_bo.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/xe/tests/xe_bo.c b/drivers/gpu/drm/xe/tests/xe_bo.c
index 412b2e7ce40c..3436fd9cf2b2 100644
--- a/drivers/gpu/drm/xe/tests/xe_bo.c
+++ b/drivers/gpu/drm/xe/tests/xe_bo.c
@@ -125,14 +125,13 @@ static void ccs_test_run_tile(struct xe_device *xe, struct xe_tile *tile,
 
 	bo = xe_bo_create_user(xe, NULL, NULL, SZ_1M, DRM_XE_GEM_CPU_CACHING_WC,
 			       ttm_bo_type_device, bo_flags);
-
-	xe_bo_lock(bo, false);
-
 	if (IS_ERR(bo)) {
 		KUNIT_FAIL(test, "Failed to create bo.\n");
 		return;
 	}
 
+	xe_bo_lock(bo, false);
+
 	kunit_info(test, "Verifying that CCS data is cleared on creation.\n");
 	ret = ccs_test_migrate(tile, bo, false, 0ULL, 0xdeadbeefdeadbeefULL,
 			       test);
-- 
2.42.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/xe/selftests: Fix an error pointer dereference bug
  2024-01-05 12:20 [PATCH] drm/xe/selftests: Fix an error pointer dereference bug Dan Carpenter
@ 2024-01-05 20:25 ` Matthew Brost
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Brost @ 2024-01-05 20:25 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Himal Prasad Ghimiray, Lucas De Marchi, Oded Gabbay,
	Thomas Hellström, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Daniel Vetter, Rodrigo Vivi,
	Matthew Auld, Nirmoy Das, Matt Roper, Pallavi Mishra, intel-xe,
	dri-devel, linux-kernel, kernel-janitors

On Fri, Jan 05, 2024 at 03:20:35PM +0300, Dan Carpenter wrote:
> Check if "bo" is an error pointer before calling xe_bo_lock() on it.
> 
> Fixes: d6abc18d6693 ("drm/xe/xe2: Modify xe_bo_test for system memory")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Matthew Brost <matthew.brost@intel.com>

> ---
>  drivers/gpu/drm/xe/tests/xe_bo.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/tests/xe_bo.c b/drivers/gpu/drm/xe/tests/xe_bo.c
> index 412b2e7ce40c..3436fd9cf2b2 100644
> --- a/drivers/gpu/drm/xe/tests/xe_bo.c
> +++ b/drivers/gpu/drm/xe/tests/xe_bo.c
> @@ -125,14 +125,13 @@ static void ccs_test_run_tile(struct xe_device *xe, struct xe_tile *tile,
>  
>  	bo = xe_bo_create_user(xe, NULL, NULL, SZ_1M, DRM_XE_GEM_CPU_CACHING_WC,
>  			       ttm_bo_type_device, bo_flags);
> -
> -	xe_bo_lock(bo, false);
> -
>  	if (IS_ERR(bo)) {
>  		KUNIT_FAIL(test, "Failed to create bo.\n");
>  		return;
>  	}
>  
> +	xe_bo_lock(bo, false);
> +
>  	kunit_info(test, "Verifying that CCS data is cleared on creation.\n");
>  	ret = ccs_test_migrate(tile, bo, false, 0ULL, 0xdeadbeefdeadbeefULL,
>  			       test);
> -- 
> 2.42.0
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-05 20:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-05 12:20 [PATCH] drm/xe/selftests: Fix an error pointer dereference bug Dan Carpenter
2024-01-05 20:25 ` Matthew Brost

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®