Skip to content

Commit 99fa42f

Browse files
committed
HID: appletb-kbd: fix "appletb_backlight" backlight device reference counting
JIRA: https://issues.redhat.com/browse/RHEL-101770 Upstream Status: 6.16-rc Tested: with the hid-tools test suite and some hardware commit 4540e41 Author: Qasim Ijaz <qasdev00@gmail.com> Date: Sun Jun 15 23:59:41 2025 +0100 HID: appletb-kbd: fix "appletb_backlight" backlight device reference counting During appletb_kbd_probe, probe attempts to get the backlight device by name. When this happens backlight_device_get_by_name looks for a device in the backlight class which has name "appletb_backlight" and upon finding a match it increments the reference count for the device and returns it to the caller. However this reference is never released leading to a reference leak. Fix this by decrementing the backlight device reference count on removal via put_device and on probe failure. Fixes: 93a0fc4 ("HID: hid-appletb-kbd: add support for automatic brightness control while using the touchbar") Cc: stable@vger.kernel.org Signed-off-by: Qasim Ijaz <qasdev00@gmail.com> Reviewed-by: Aditya Garg <gargaditya08@live.com> Signed-off-by: Jiri Kosina <jkosina@suse.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
1 parent 6153c53 commit 99fa42f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/hid/hid-appletb-kbd.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,8 @@ static int appletb_kbd_probe(struct hid_device *hdev, const struct hid_device_id
437437
unregister_handler:
438438
input_unregister_handler(&kbd->inp_handler);
439439
close_hw:
440+
if (kbd->backlight_dev)
441+
put_device(&kbd->backlight_dev->dev);
440442
hid_hw_close(hdev);
441443
stop_hw:
442444
hid_hw_stop(hdev);
@@ -452,6 +454,9 @@ static void appletb_kbd_remove(struct hid_device *hdev)
452454
input_unregister_handler(&kbd->inp_handler);
453455
del_timer_sync(&kbd->inactivity_timer);
454456

457+
if (kbd->backlight_dev)
458+
put_device(&kbd->backlight_dev->dev);
459+
455460
hid_hw_close(hdev);
456461
hid_hw_stop(hdev);
457462
}

0 commit comments

Comments
 (0)