hwmon: (applesmc) fix key backlight workqueue leak on register failure
Subsystems (2)
PATCH 1/1 hwmon: (applesmc) fix key backlight workqueue leak on register failure
applesmc_create_key_backlight() allocates applesmc_led_wq before calling led_classdev_register(). When register fails, the error is returned to applesmc_init(), which jumps to out_light_sysfs and skips applesmc_release_key_backlight(), leaking the workqueue.
Destroy the workqueue on the register failure path. The bug was introduced when the inline init block was refactored into a helper that returns errors directly, dropping the old out_light_wq unwind label.
--- drivers/hwmon/applesmc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/hwmon/applesmc.c +6 -1
@@ -1249,12 +1249,17 @@ static void applesmc_release_light_sensor(void)static int applesmc_create_key_backlight (void ) { +int ret; +if (!smcreg.has_key_backlight)return 0 ; applesmc_led_wq =create_singlethread_workqueue ("applesmc-led" );if (!applesmc_led_wq)return -ENOMEM ; -return led_classdev_register (&pdev->dev, &applesmc_backlight); + ret =led_classdev_register (&pdev->dev, &applesmc_backlight); +if (ret) +destroy_workqueue (applesmc_led_wq); +return ret; }static void applesmc_release_key_backlight (void )
Signature · 1 line
2.25.1
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines
applesmc_create_key_backlight()allocatesapplesmc_led_wqbefore callingled_classdev_register(). When register fails, the error is returned toapplesmc_init(), which jumps toout_light_sysfsand skipsapplesmc_release_key_backlight(), leaking the workqueue.
Quoted 8 lines
Destroy the workqueue on the register failure path. The bug was introduced when the inline init block was refactored into a helper that returns errors directly, dropping the old
out_light_wqunwind label.Fixes 0b0b5dff8967 ("hwmon: (applesmc) Simplify feature sysfs handling")Assisted-by Claude:claude-opus-4Signed-off-by Cong Nguyen <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 5 lines · Cong Nguyen
applesmc_create_key_backlight()allocatesapplesmc_led_wqbefore callingled_classdev_register(). When register fails, the error is returned toapplesmc_init(), which jumps toout_light_sysfsand skipsapplesmc_release_key_backlight(), leaking the workqueue.
Quoted 8 lines
Destroy the workqueue on the register failure path. The bug was introduced when the inline init block was refactored into a helper that returns errors directly, dropping the old
out_light_wqunwind label.Fixes 0b0b5dff8967 ("hwmon: (applesmc) Simplify feature sysfs handling")Assisted-by Claude:claude-opus-4Signed-off-by Cong Nguyen <[email protected]>
Applied.
Thanks,
Guenter