[PATCH] drm/xe: validate client of BO inside lock

Tejas Upadhyay tejas.upadhyay at intel.com
Mon Jun 3 14:28:23 UTC 2024


As client of BO getting referenced inside lock of BOs
list, its good practice to move these WARN_ONs also
under same lock to validate existance of bo->client.

Signed-off-by: Tejas Upadhyay <tejas.upadhyay at intel.com>
---
 drivers/gpu/drm/xe/xe_drm_client.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_drm_client.c b/drivers/gpu/drm/xe/xe_drm_client.c
index 4a19b771e3a0..7881b02fa117 100644
--- a/drivers/gpu/drm/xe/xe_drm_client.c
+++ b/drivers/gpu/drm/xe/xe_drm_client.c
@@ -131,10 +131,9 @@ void __xe_drm_client_free(struct kref *kref)
 void xe_drm_client_add_bo(struct xe_drm_client *client,
 			  struct xe_bo *bo)
 {
+	spin_lock(&client->bos_lock);
 	XE_WARN_ON(bo->client);
 	XE_WARN_ON(!list_empty(&bo->client_link));
-
-	spin_lock(&client->bos_lock);
 	bo->client = xe_drm_client_get(client);
 	list_add_tail(&bo->client_link, &client->bos_list);
 	spin_unlock(&client->bos_lock);
-- 
2.25.1



More information about the Intel-xe mailing list