[PATCH v2 1/2] platform/chrome: cros_ec_debugfs: clean up console log on probe failure
From: Hongyan Xu
Date: Wed Jul 29 2026 - 07:28:26 EST
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 <getshell@xxxxxxxxxx>
---
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/20260728123423.781-3-getshell@xxxxxxxxxx
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