firmware: arm_scmi: Fix the double free in scmi_debugfs_common_setup()
authorSu Hui <suhui@nfschina.com>
Fri, 11 Oct 2024 10:40:02 +0000 (18:40 +0800)
committerSudeep Holla <sudeep.holla@arm.com>
Fri, 11 Oct 2024 15:52:42 +0000 (16:52 +0100)
Clang static checker(scan-build) throws below warning:
  |  drivers/firmware/arm_scmi/driver.c:line 2915, column 2
  |        Attempt to free released memory.

When devm_add_action_or_reset() fails, scmi_debugfs_common_cleanup()
will run twice which causes 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>
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Message-Id: <20241011104001.1546476-1-suhui@nfschina.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
drivers/firmware/arm_scmi/driver.c

index 88c5c4ff4bb62ee313da275880a9c85bc67fb38a..a477b5ade38dcac8517beeee7ff2908da9ea1d8f 100644 (file)
@@ -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;
 }