Skip to content

Commit 5dcaa73

Browse files
committed
HID: wacom: fix memory leak on kobject creation failure
JIRA: https://issues.redhat.com/browse/RHEL-102058 Upstream Status: v6.16 commit 5ae416c Author: Qasim Ijaz <qasdev00@gmail.com> Date: Fri Jun 6 19:49:57 2025 +0100 HID: wacom: fix memory leak on kobject creation failure During wacom_initialize_remotes() a fifo buffer is allocated with kfifo_alloc() and later a cleanup action is registered during devm_add_action_or_reset() to clean it up. However if the code fails to create a kobject and register it with sysfs the code simply returns -ENOMEM before the cleanup action is registered leading to a memory leak. Fix this by ensuring the fifo is freed when the kobject creation and registration process fails. Fixes: 83e6b40 ("HID: wacom: EKR: have the wacom resources dynamically allocated") Reviewed-by: Ping Cheng <ping.cheng@wacom.com> Cc: stable@vger.kernel.org Signed-off-by: Qasim Ijaz <qasdev00@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
1 parent e446ab7 commit 5dcaa73

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/hid/wacom_sys.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2046,8 +2046,10 @@ static int wacom_initialize_remotes(struct wacom *wacom)
20462046

20472047
remote->remote_dir = kobject_create_and_add("wacom_remote",
20482048
&wacom->hdev->dev.kobj);
2049-
if (!remote->remote_dir)
2049+
if (!remote->remote_dir) {
2050+
kfifo_free(&remote->remote_fifo);
20502051
return -ENOMEM;
2052+
}
20512053

20522054
error = sysfs_create_files(remote->remote_dir, remote_unpair_attrs);
20532055

0 commit comments

Comments
 (0)