Skip to contentSkip to conversation

drm/amdkfd: Fix error handling in kfd_criu_restore_events

PATCH In review Felix Kuehling 2 participants 2 messages Nov 3, 2022 – Nov 4, 2022

Subsystems (3)
lore
Share & tools
lore

Felix Kuehling

author maintainer
#0 lore raw

PATCH 1/1 drm/amdkfd: Fix error handling in kfd_criu_restore_events

mutex_unlock before the exit label because all the error code paths that jump there didn't take that lock. This fixes unbalanced locking errors in case of restore errors.

Fixes 40e8a766a761 ("drm/amdkfd: CRIU checkpoint and restore events")
---
 drivers/gpu/drm/amd/amdkfd/kfd_events.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_events.c +1 -2
index 83e3ce9f6049..729d26d648af 100644
@@ -506,6 +506,7 @@ int kfd_criu_restore_event(struct file *devkfd,
 		ret = create_other_event(p, ev, &ev_priv->event_id);
 		break;
 	}
+	mutex_unlock(&p->event_mutex);
 
 exit:
 	if (ret)
@@ -513,8 +514,6 @@ int kfd_criu_restore_event(struct file *devkfd,
 
 	kfree(ev_priv);
 
-	mutex_unlock(&p->event_mutex);
-
 	return ret;
 }
 
Signature · 1 line
2.32.0
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only - General]

Yes it helps avoid the unbalanced lock messages seen during criu restore failures for events. Looks good to me.

Regards,
Rajneesh
________________________________
From: amd-gfx <[email protected]> on behalf of Felix Kuehling <[email protected]>
Sent: Thursday, November 3, 2022 7:13:09 PM
To: [email protected] <[email protected]>
Subject: [PATCH] drm/amdkfd: Fix error handling in kfd_criu_restore_events

mutex_unlock before the exit label because all the error code paths that jump there didn't take that lock. This fixes unbalanced locking errors in case of restore errors.

Fixes 40e8a766a761 ("drm/amdkfd: CRIU checkpoint and restore events")
---
 drivers/gpu/drm/amd/amdkfd/kfd_events.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_events.c +1 -2
index 83e3ce9f6049..729d26d648af 100644
@@ -506,6 +506,7 @@ int kfd_criu_restore_event(struct file *devkfd,
                 ret = create_other_event(p, ev, &ev_priv->event_id);
                 break;
         }
+       mutex_unlock(&p->event_mutex);
 
 exit:
         if (ret)
@@ -513,8 +514,6 @@ int kfd_criu_restore_event(struct file *devkfd,
 
         kfree(ev_priv);
 
-       mutex_unlock(&p->event_mutex);
-
         return ret;
 }
 

--
2.32.0