]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: cec: Fix debugfs leak on bus_register() failure
authorHaotian Zhang <vulab@iscas.ac.cn>
Mon, 29 Sep 2025 11:12:29 +0000 (19:12 +0800)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Tue, 14 Oct 2025 13:07:37 +0000 (15:07 +0200)
In cec_devnode_init(), the debugfs directory created with
debugfs_create_dir() is not removed if bus_register() fails.
This leaves a stale "cec" entry in debugfs and prevents
proper module reloading.

Fix this by removing the debugfs directory in the error path.

Fixes: a56960e8b406 ("[media] cec: add HDMI CEC framework (core)")
Cc: stable@vger.kernel.org
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/cec/core/cec-core.c

index d7259599029f8b1b9060a5f3cbc69ae72977a02f..dd6e24a0899bda15ccb61c48991175a3cb29013e 100644 (file)
@@ -421,6 +421,7 @@ static int __init cec_devnode_init(void)
 
        ret = bus_register(&cec_bus_type);
        if (ret < 0) {
+               debugfs_remove_recursive(top_cec_dir);
                unregister_chrdev_region(cec_dev_t, CEC_NUM_DEVICES);
                pr_warn("cec: bus_register failed\n");
                return -EIO;