gpio: mockup: fix resource leak in error path
Subsystems (3)
PATCH 1/1 gpio: mockup: fix resource leak in error path
From: Bartosz Golaszewski <[email protected]>
If the module init function fails after creating the debugs directory, it's never removed. Add proper cleanup calls to avoid this resource leak.
Fixes 9202ba2397d1 ("gpio: mockup: implement event injecting over debugfs")
Cc <[email protected]>
Signed-off-by Bartosz Golaszewski <[email protected]>
--- drivers/gpio/gpio-mockup.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpio/gpio-mockup.c +2 -0
@@ -552,6 +552,7 @@ static int __init gpio_mockup_init(void) err =platform_driver_register (&gpio_mockup_driver);if (err) {gpio_mockup_err ("error registering platform driver\n" ); +debugfs_remove_recursive (gpio_mockup_dbg_dir);return err; }
@@ -582,6 +583,7 @@ static int __init gpio_mockup_init(void)gpio_mockup_err ("error registering device" );platform_driver_unregister (&gpio_mockup_driver);gpio_mockup_unregister_pdevs (); +debugfs_remove_recursive (gpio_mockup_dbg_dir);return PTR_ERR (pdev); }
Signature · 1 line
2.26.1
Quoted 5 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
If the module init function fails after creating the debugs directory, it's never removed. Add proper cleanup calls to avoid this resource leak.
Reviewed-by Andy Shevchenko <[email protected]>
Quoted 30 lines
Fixes 9202ba2397d1 ("gpio: mockup: implement event injecting over debugfs")Cc <[email protected]>Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/gpio/gpio-mockup.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpio/gpio-mockup.c +2
-0@@ -552,6 +552,7 @@ static int __init gpio_mockup_init(void) err =platform_driver_register (&gpio_mockup_driver);if (err) {gpio_mockup_err ("error registering platform driver\n" ); +debugfs_remove_recursive (gpio_mockup_dbg_dir);return err; }@@ -582,6 +583,7 @@ static int __init gpio_mockup_init(void)gpio_mockup_err ("error registering device" );platform_driver_unregister (&gpio_mockup_driver);gpio_mockup_unregister_pdevs (); +debugfs_remove_recursive (gpio_mockup_dbg_dir);return PTR_ERR (pdev); }Signature · 1 line
2.26.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 9 lines · Andy Shevchenko
Quoted 5 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
If the module init function fails after creating the debugs directory, it's never removed. Add proper cleanup calls to avoid this resource leak.
Reviewed-by Andy Shevchenko <[email protected]>
Thanks. This is uncontroversial so I queued right away for fixes.
Bartosz