Skip to contentSkip to conversation

drm/amdkfd: fix a dereference of pdd before it is null checked

PATCH Applied Colin King 2 participants 2 messages May 28, 2020 – May 29, 2020

Subsystems (4)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 drm/amdkfd: fix a dereference of pdd before it is null checked

From: Colin Ian King <[email protected]>

Currently pointer pdd is being dereferenced when assigning pointer dpm and then pdd is being null checked. Fix this by checking if pdd is null before the dereference of pdd occurs.

Addresses-Coverity: ("Dereference before null check")

Fixes 522b89c63370 ("drm/amdkfd: Track SDMA utilization per process")
---
 drivers/gpu/drm/amd/amdkfd/kfd_process.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_process.c +3 -2
index 25636789f3d3..bdc58741b32e 100644
@@ -103,10 +103,11 @@ static void kfd_sdma_activity_worker(struct work_struct *work)
 		return;
 
 	pdd = workarea->pdd;
+	if (!pdd)
+		return;
 	dqm = pdd->dev->dqm;
 	qpd = &pdd->qpd;
-
-	if (!pdd || !dqm || !qpd)
+	if (!dqm || !qpd)
 		return;
 
 	mm = get_task_mm(pdd->process->lead_thread);
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 1/1 Applied
#1 lore raw
Quoted 9 lines · Colin King

From: Colin Ian King <[email protected]>

Currently pointer pdd is being dereferenced when assigning pointer dpm and then pdd is being null checked. Fix this by checking if pdd is null before the dereference of pdd occurs.

Addresses-Coverity: ("Dereference before null check")

Fixes 522b89c63370 ("drm/amdkfd: Track SDMA utilization per process")

I applied the patch to our internal amd-staging-drm-next.

Regards,
  Felix

Quoted 22 lines
---
  drivers/gpu/drm/amd/amdkfd/kfd_process.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_process.c +3 -2
index 25636789f3d3..bdc58741b32e 100644
@@ -103,10 +103,11 @@ static void kfd_sdma_activity_worker(struct work_struct *work)
  		return;
 
  	pdd = workarea->pdd;
+	if (!pdd)
+		return;
  	dqm = pdd->dev->dqm;
  	qpd = &pdd->qpd;
-
-	if (!pdd || !dqm || !qpd)
+	if (!dqm || !qpd)
  		return;
 
  	mm = get_task_mm(pdd->process->lead_thread);