[PATCH v2 1/2] platform/chrome: cros_ec_debugfs: clean up console log on probe failure

Hongyan Xu <[email protected]> Wed, 29 Jul 2026 18:32:16 +0800
Newsgroups dev.linux.lists.chrome-platform,org.kernel.vger.linux-kernel
Message-ID <c00974953a1b952f51f0f021d7f9fad134159909.1785320940.git.getshell@seu.edu.cn>
cros_ec_create_console_log() starts log_poll_work when console logging is
supported. If the following panic notifier registration fails, probe
removes the debugfs entries but leaves the delayed work scheduled. The
work can then access devm-managed data after the failed probe tears it
down.

Add a dedicated error label for failures after successful console log
setup. Earlier failures keep using the existing debugfs-only cleanup
path.

This issue was found by a static analysis tool.

Fixes: d90fa2c64d59 ("platform/chrome: cros_ec: Poll EC log on EC panic")
Signed-off-by: Hongyan Xu <[email protected]>
---
Changes in v2:
- Split the console log probe cleanup into a separate patch.
- Add a dedicated cleanup_console_log error label.

Link to v1: https://lore.kernel.org/r/[email protected]

 drivers/platform/chrome/cros_ec_debugfs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/chrome/cros_ec_debugfs.c b/drivers/platform/chrome/cros_ec_debugfs.c
index 92ac9a2..a781bb5 100644
--- a/drivers/platform/chrome/cros_ec_debugfs.c
+++ b/drivers/platform/chrome/cros_ec_debugfs.c
@@ -525,7 +525,7 @@ static int cros_ec_debugfs_probe(struct platform_device *pd)
 	ret = blocking_notifier_chain_register(&ec->ec_dev->panic_notifier,
 					       &debug_info->notifier_panic);
 	if (ret)
-		goto remove_debugfs;
+		goto cleanup_console_log;
 
 	ec->debug_info = debug_info;
 
@@ -533,6 +533,8 @@ static int cros_ec_debugfs_probe(struct platform_device *pd)
 
 	return 0;
 
+cleanup_console_log:
+	cros_ec_cleanup_console_log(debug_info);
 remove_debugfs:
 	debugfs_remove_recursive(debug_info->dir);
 	return ret;
-- 
2.50.1.windows.1