linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] firmware: arm_scmi: fix the double free in scmi_debugfs_common_setup()
@ 2024-10-11 10:40 Su Hui
  2024-10-11 14:25 ` Cristian Marussi
  2024-10-15 13:15 ` Sudeep Holla
  0 siblings, 2 replies; 3+ messages in thread
From: Su Hui @ 2024-10-11 10:40 UTC (permalink / raw)
  To: sudeep.holla, cristian.marussi, nathan, ndesaulniers, morbo,
	justinstitt
  Cc: Su Hui, arm-scmi, linux-arm-kernel, linux-kernel, llvm,
	kernel-janitors

Clang static checker(scan-build) warning:
drivers/firmware/arm_scmi/driver.c:line 2915, column 2
Attempt to free released memory.

When devm_add_action_or_reset() failed , scmi_debugfs_common_cleanup()
will run twice which caused double free of 'dbg->name'.
Remove the redundant scmi_debugfs_common_cleanup() to fix this problem.

Fixes: c3d4aed763ce ("firmware: arm_scmi: Populate a common SCMI debugfs root")
Signed-off-by: Su Hui <suhui@nfschina.com>
---
 drivers/firmware/arm_scmi/driver.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 88c5c4ff4bb6..a477b5ade38d 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -2976,10 +2976,8 @@ static struct scmi_debug_info *scmi_debugfs_common_setup(struct scmi_info *info)
 	dbg->top_dentry = top_dentry;
 
 	if (devm_add_action_or_reset(info->dev,
-				     scmi_debugfs_common_cleanup, dbg)) {
-		scmi_debugfs_common_cleanup(dbg);
+				     scmi_debugfs_common_cleanup, dbg))
 		return NULL;
-	}
 
 	return dbg;
 }
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] firmware: arm_scmi: fix the double free in scmi_debugfs_common_setup()
  2024-10-11 10:40 [PATCH] firmware: arm_scmi: fix the double free in scmi_debugfs_common_setup() Su Hui
@ 2024-10-11 14:25 ` Cristian Marussi
  2024-10-15 13:15 ` Sudeep Holla
  1 sibling, 0 replies; 3+ messages in thread
From: Cristian Marussi @ 2024-10-11 14:25 UTC (permalink / raw)
  To: Su Hui
  Cc: sudeep.holla, cristian.marussi, nathan, ndesaulniers, morbo,
	justinstitt, arm-scmi, linux-arm-kernel, linux-kernel, llvm,
	kernel-janitors

On Fri, Oct 11, 2024 at 06:40:02PM +0800, Su Hui wrote:
> Clang static checker(scan-build) warning:
> drivers/firmware/arm_scmi/driver.c:line 2915, column 2
> Attempt to free released memory.
> 
> When devm_add_action_or_reset() failed , scmi_debugfs_common_cleanup()
> will run twice which caused double free of 'dbg->name'.
> Remove the redundant scmi_debugfs_common_cleanup() to fix this problem.
> 

Oh Yes...my bad, Good Catch !

LGTM.
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>

Thanks,
Cristian


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] firmware: arm_scmi: fix the double free in scmi_debugfs_common_setup()
  2024-10-11 10:40 [PATCH] firmware: arm_scmi: fix the double free in scmi_debugfs_common_setup() Su Hui
  2024-10-11 14:25 ` Cristian Marussi
@ 2024-10-15 13:15 ` Sudeep Holla
  1 sibling, 0 replies; 3+ messages in thread
From: Sudeep Holla @ 2024-10-15 13:15 UTC (permalink / raw)
  To: cristian.marussi, nathan, ndesaulniers, morbo, justinstitt,
	Su Hui
  Cc: Sudeep Holla, arm-scmi, linux-arm-kernel, linux-kernel, llvm,
	kernel-janitors

On Fri, 11 Oct 2024 18:40:02 +0800, Su Hui wrote:
> Clang static checker(scan-build) warning:
> drivers/firmware/arm_scmi/driver.c:line 2915, column 2
> Attempt to free released memory.
> 
> When devm_add_action_or_reset() failed , scmi_debugfs_common_cleanup()
> will run twice which caused double free of 'dbg->name'.
> Remove the redundant scmi_debugfs_common_cleanup() to fix this problem.
> 
> [...]

Applied to sudeep.holla/linux (for-next/scmi/fixes), thanks!

[1/1] firmware: arm_scmi: fix the double free in scmi_debugfs_common_setup()
      https://git.kernel.org/sudeep.holla/c/39b13dce1a91
--
Regards,
Sudeep



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-15 13:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-11 10:40 [PATCH] firmware: arm_scmi: fix the double free in scmi_debugfs_common_setup() Su Hui
2024-10-11 14:25 ` Cristian Marussi
2024-10-15 13:15 ` Sudeep Holla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).