Message ID | 20240411031903.3050278-2-chengzhihao1@huawei.com |
---|---|
State | Superseded |
Delegated to: | Richard Weinberger |
Headers | show |
Series | ubi: Fix serious of resource leaking problems | expand |
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index a7e3a6246c0e..7f95fd7968a8 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -1372,7 +1372,7 @@ static int __init ubi_init(void) /* See comment above re-ubi_is_module(). */ if (ubi_is_module()) - goto out_slab; + goto out_debugfs; } register_mtd_user(&ubi_mtd_notifier); @@ -1387,6 +1387,8 @@ static int __init ubi_init(void) out_mtd_notifier: unregister_mtd_user(&ubi_mtd_notifier); +out_debugfs: + ubi_debugfs_exit(); out_slab: kmem_cache_destroy(ubi_wl_entry_slab); out_dev_unreg:
The debugfs dir is created in ubi_init, but it is not destroyed in error handling path of ubi_init when ubi is loaded by inserting module (eg. attaching failure), which leads to subsequent ubi_init calls failed. Fix it by destroying debugfs dir in corresponding error handling path. Fixes: 927c145208b0 ("mtd: ubi: attach from device tree") Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> --- drivers/mtd/ubi/build.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)