Skip to contentSkip to conversation

drm/amd/powerplay: Fix double unlock bug in smu_sys_set_pp_table()

PATCH In review Dan Carpenter 4 participants 6 messages Mar 21, 2019 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/powerplay: Fix double unlock bug in smu_sys_set_pp_table()

We already unlocked a few lines earlier so this code unlocks twice on the success path.

Fixes 5809d7420f97 ("drm/amd/powerplay: implement sysfs of pp_table for smu11 (v2)")

---
I'm not sure what this bug looks like at runtime, but it's slightly weird that no one noticed. This is from static analysis and I haven't tested it myself.

 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +2 -0
index 00b7c885772b..7e8c74da6a74 100644
@@ -187,6 +187,8 @@ int smu_sys_set_pp_table(struct smu_context *smu,  void *buf, size_t size)
 	if (ret)
 		pr_info("smu reset failed, ret = %d\n", ret);
 
+	return ret;
+
 failed:
 	mutex_unlock(&smu->mutex);
 	return ret;
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by Huang Rui on v1 1/1
#1 lore raw
Quoted 13 lines

-----Original Message-----
From: Dan Carpenter [mailto:[email protected]]
Sent: Thursday, March 21, 2019 2:28 PM
To: Deucher, Alexander <[email protected]>; Wang, Kevin(Yang) <[email protected]>
Cc: Koenig, Christian <[email protected]>; Zhou, David(ChunMing) <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; Huang, Ray <[email protected]>; Gao, Likun <[email protected]>; Gui, Jack <[email protected]>; amd- [email protected]; [email protected]
Subject: [PATCH] drm/amd/powerplay: Fix double unlock bug in smu_sys_set_pp_table()

Quoted 6 lines

We already unlocked a few lines earlier so this code unlocks twice on the success path.

Fixes 5809d7420f97 ("drm/amd/powerplay: implement sysfs of pp_table for

smu11 (v2)")

Nice catch! Thanks, Dan.
Kevin, could you please verify this patch.

Quoted 21 lines

---
I'm not sure what this bug looks like at runtime, but it's slightly weird that no one noticed. This is from static analysis and I haven't tested it myself.

 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +2 -0
index 00b7c885772b..7e8c74da6a74 100644
@@ -187,6 +187,8 @@ int smu_sys_set_pp_table(struct smu_context *smu,
 void *buf, size_t size)
 	if (ret)
 		pr_info("smu reset failed, ret = %d\n", ret);
 
+	return ret;
+
 failed:
 	mutex_unlock(&smu->mutex);
Quoted 3 lines

return ret;
--
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): MN2PR12MB3309B7C391B32EB8F5F87676EC420-rweVpJHSKTpWdvXm18W95QdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#3 lore raw
Quoted 41 lines · Ray
Quoted 13 lines

-----Original Message-----
From: Dan Carpenter [mailto:[email protected]]
Sent: Thursday, March 21, 2019 2:28 PM
To: Deucher, Alexander <[email protected]>; Wang, Kevin(Yang) <[email protected]>
Cc: Koenig, Christian <[email protected]>; Zhou, David(ChunMing) <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; Huang, Ray <[email protected]>; Gao, Likun <[email protected]>; Gui, Jack <[email protected]>; amd- [email protected]; [email protected]
Subject: [PATCH] drm/amd/powerplay: Fix double unlock bug in smu_sys_set_pp_table()

Quoted 6 lines

We already unlocked a few lines earlier so this code unlocks twice on the success path.

Fixes 5809d7420f97 ("drm/amd/powerplay: implement sysfs of pp_table for

smu11 (v2)")

Nice catch! Thanks, Dan.
Kevin, could you please verify this patch.

Quoted 17 lines

---
I'm not sure what this bug looks like at runtime, but it's slightly weird that no one noticed. This is from static analysis and I haven't tested it myself.

 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +0 -0
index 00b7c885772b..7e8c74da6a74 100644
@@ -187,6 +187,8 @@ int smu_sys_set_pp_table(struct smu_context *smu,
 void *buf, size_t size)
 	if (ret)
 		pr_info("smu reset failed, ret = %d\n", ret);
 
Quoted 1 line

drivers/gpu/drm/amd/powerplay/amdgpu_smu.c int smu_sys_set_pp_table(struct smu_context *smu, void *buf, size_t size) · line 190

Quoted 1 line
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +1 -0
+	return ret;

Why not return 0?

julia

Quoted 8 lines
Quoted 6 lines
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +1 -0
+
 failed:
 	mutex_unlock(&smu->mutex);

return ret;
--
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#4 lore raw
Quoted 45 lines · Julia Lawall
Quoted 41 lines · Ray
Quoted 13 lines

-----Original Message-----
From: Dan Carpenter [mailto:[email protected]]
Sent: Thursday, March 21, 2019 2:28 PM
To: Deucher, Alexander <[email protected]>; Wang, Kevin(Yang) <[email protected]>
Cc: Koenig, Christian <[email protected]>; Zhou, David(ChunMing) <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; Huang, Ray <[email protected]>; Gao, Likun <[email protected]>; Gui, Jack <[email protected]>; amd- [email protected]; [email protected]
Subject: [PATCH] drm/amd/powerplay: Fix double unlock bug in smu_sys_set_pp_table()

Quoted 6 lines

We already unlocked a few lines earlier so this code unlocks twice on the success path.

Fixes 5809d7420f97 ("drm/amd/powerplay: implement sysfs of pp_table for

smu11 (v2)")

Nice catch! Thanks, Dan.
Kevin, could you please verify this patch.

Quoted 17 lines

---
I'm not sure what this bug looks like at runtime, but it's slightly weird that no one noticed. This is from static analysis and I haven't tested it myself.

 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +0 -0
index 00b7c885772b..7e8c74da6a74 100644
@@ -187,6 +187,8 @@ int smu_sys_set_pp_table(struct smu_context *smu,
 void *buf, size_t size)
 	if (ret)
 		pr_info("smu reset failed, ret = %d\n", ret);
 
Quoted 3 lines
Quoted 1 line

drivers/gpu/drm/amd/powerplay/amdgpu_smu.c int smu_sys_set_pp_table(struct smu_context *smu, void *buf, size_t size) · line 190

Quoted 1 line
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +1 -0
+	return ret;

Why not return 0?

It's not necessarily zero.

regards,
dan carpenter

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#5 lore raw
Quoted 46 lines · Dan Carpenter
Quoted 45 lines · Julia Lawall
Quoted 41 lines · Ray
Quoted 13 lines

-----Original Message-----
From: Dan Carpenter [mailto:[email protected]]
Sent: Thursday, March 21, 2019 2:28 PM
To: Deucher, Alexander <[email protected]>; Wang, Kevin(Yang) <[email protected]>
Cc: Koenig, Christian <[email protected]>; Zhou, David(ChunMing) <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; Huang, Ray <[email protected]>; Gao, Likun <[email protected]>; Gui, Jack <[email protected]>; amd- [email protected]; [email protected]
Subject: [PATCH] drm/amd/powerplay: Fix double unlock bug in smu_sys_set_pp_table()

Quoted 6 lines

We already unlocked a few lines earlier so this code unlocks twice on the success path.

Fixes 5809d7420f97 ("drm/amd/powerplay: implement sysfs of pp_table for

smu11 (v2)")

Nice catch! Thanks, Dan.
Kevin, could you please verify this patch.

Quoted 17 lines

---
I'm not sure what this bug looks like at runtime, but it's slightly weird that no one noticed. This is from static analysis and I haven't tested it myself.

 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +0 -0
index 00b7c885772b..7e8c74da6a74 100644
@@ -187,6 +187,8 @@ int smu_sys_set_pp_table(struct smu_context *smu,
 void *buf, size_t size)
 	if (ret)
 		pr_info("smu reset failed, ret = %d\n", ret);
 
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

drivers/gpu/drm/amd/powerplay/amdgpu_smu.c int smu_sys_set_pp_table(struct smu_context *smu, void *buf, size_t size) · line 190

Quoted 1 line
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +1 -0
+	return ret;

Why not return 0?

It's not necessarily zero.

Oops, I was looking at the invisble goto after the pr_info :)

julia
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by on v1 1/1
#6 lore raw
In reply to Dan Carpenter

Hi Dan,

Thank you for your careful attention to the problem.
I made the mistake of this patch, when we do code rebase internally. and your patch is looks fine for me.

Thanks.

Best Regards,
Kevin

________________________________
From: Dan Carpenter <[email protected]>
Sent: Thursday, March 21, 2019 2:28:22 PM
To: Deucher, Alexander; Wang, Kevin(Yang)
Cc: Koenig, Christian; Zhou, David(ChunMing); David Airlie; Daniel Vetter; Huang, Ray; Gao, Likun; Gui, Jack; [email protected]; [email protected]
Subject: [PATCH] drm/amd/powerplay: Fix double unlock bug in smu_sys_set_pp_table()

We already unlocked a few lines earlier so this code unlocks twice on the success path.

Fixes 5809d7420f97 ("drm/amd/powerplay: implement sysfs of pp_table for smu11 (v2)")

---
I'm not sure what this bug looks like at runtime, but it's slightly weird that no one noticed. This is from static analysis and I haven't tested it myself.

 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +2 -0
index 00b7c885772b..7e8c74da6a74 100644
@@ -187,6 +187,8 @@ int smu_sys_set_pp_table(struct smu_context *smu,  void *buf, size_t size)
         if (ret)
                 pr_info("smu reset failed, ret = %d\n", ret);
 
+       return ret;
+
 failed:
         mutex_unlock(&smu->mutex);
         return ret;

--
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx