[PATCH 8/8] platform/chrome: cros_ec_chardev: Use misc_sync_register()

Tzung-Bi Shih
2026-04-27T13:47:59Z

Switch to use misc_sync_register() instead of misc_register() to
enable synchronous file operations support. This helps prevent
Use-After-Free errors when the device is removed while files are still
open.

Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
---
drivers/platform/chrome/cros_ec_chardev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/chrome/cros_ec_chardev.c b/drivers/platform/chrome/cros_ec_chardev.c
index 7e046fc56998..d44afa3ef92d 100644
--- a/drivers/platform/chrome/cros_ec_chardev.c
+++ b/drivers/platform/chrome/cros_ec_chardev.c
@@ -430,7 +430,7 @@ static int cros_ec_chardev_probe(struct platform_device *pdev)
pdata->misc.name = ec_platform->ec_name;
pdata->misc.parent = pdev->dev.parent;

- ret = misc_register(&pdata->misc);
+ ret = misc_sync_register(&pdata->misc);
if (ret) {
dev_err(&pdev->dev, "failed to register misc device\n");
goto err_unregister_notifier;
--
2.51.0