drm/amdgpu: Check hive->reset_domain not NULL before releasing it.
Subsystems (2)
PATCH 1/1 drm/amdgpu: Check hive->reset_domain not NULL before releasing it.
The recent change brought a bug on SRIOV envrionment. It caused kernel crashing while unloading amdgpu on guest VM with hive configuration. The reason is that the hive->reset_domain is not used (hive->reset_domain is not initialized) for SRIOV, but the code did not check if hive->reset_domain before releasing.
The hive->reset_domain need be checked not NULL before releasing.
Fixed: d95e8e97e2d5 ("drm/amdgpu: refine create and release logic of hive info")
--- drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +9 -2
@@ -217,8 +217,15 @@ static void amdgpu_xgmi_hive_release(struct kobject *kobj)struct amdgpu_hive_info *hive =container_of ( kobj, struct amdgpu_hive_info, kobj); -amdgpu_reset_put_reset_domain (hive->reset_domain); - hive->reset_domain =NULL ; +/** +* The hive->reset_domain is only initialized for none SRIOV +* configuration. It needs to check if hive->reset_domain is +* NULL. +*/ +if (hive->reset_domain) { +amdgpu_reset_put_reset_domain (hive->reset_domain); + hive->reset_domain =NULL ; + }mutex_destroy (&hive->hive_lock);kfree (hive);
Signature · 1 line
2.34.1
Quoted 9 lines · Gavin Wan
The recent change brought a bug on SRIOV envrionment. It caused kernel crashing while unloading amdgpu on guest VM with hive configuration. The reason is that the
hive->reset_domainis not used (hive->reset_domainis not initialized) for SRIOV, but the code did not check ifhive->reset_domainbefore releasing.The
hive->reset_domainneed be checked not NULL before releasing.Fixed:
d95e8e97e2d5("drm/amdgpu: refine create and release logic of hive info")
The tag should be named "Fixes", not "Fixed".
Quoted 2 lines
Signed-off-by Gavin Wan <[email protected]>Change-Id I17189e4d7357e399c6b70e43c24051356c025a3a
Please remove the Change-Id.
Quoted 9 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c static void amdgpu_xgmi_hive_release(struct kobject *kobj) · line 220
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +1
-2@@ -217,8 +217,15 @@ static void amdgpu_xgmi_hive_release(struct kobject *kobj)struct amdgpu_hive_info *hive =container_of ( kobj, struct amdgpu_hive_info, kobj); -amdgpu_reset_put_reset_domain (hive->reset_domain); - hive->reset_domain =NULL ; +/**
Remove the extra *. /** is used to denote doc-comments, and this is not one.
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c static void amdgpu_xgmi_hive_release(struct kobject *kobj) · line 226
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +6
-0+* The hive->reset_domain is only initialized for none SRIOV +* configuration. It needs to check if hive->reset_domain is +* NULL. +*/ +if (hive->reset_domain) { +amdgpu_reset_put_reset_domain (hive->reset_domain);
It may be better to do the NULL pointer check inside amdgpu_reset_put_reset_domain. In fact, current staging already has a check there, so this patch is unnecessary. Just sync your branch. It was added by this commit:
Quoted 10 lines
commit
d6a7ab1e0168a96b6cb0e386399e54af4fe39af4
Author: Vignesh Chander <[email protected]>
Date: Wed Sep 28 14:59:45 2022 -0400drm/amdgpu: Skip
put_reset_domainif it doesn't existFor xgmi sriov, the reset is handled by host driver and
hive->reset_domainis not initialized so need to check if it exists before doing a put.Signed-off-by Vignesh Chander <[email protected]>Reviewed-by Shaoyun Liu <[email protected]>
Regards,
Felix
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +2
-0+ hive->reset_domain =NULL ; + }mutex_destroy (&hive->hive_lock);kfree (hive);