summaryrefslogtreecommitdiff
path: root/drivers/hid
diff options
context:
space:
mode:
authorQasim Ijaz <qasdev00@gmail.com>2025-06-06 19:49:57 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-07-06 11:01:44 +0200
commita85999b9876543aa9b7a204ee2a660e1d1806262 (patch)
tree24690d8df1cc384cb8e5817a5384393199ddee44 /drivers/hid
parent4b4b639cc50a8101c27a64c3fb63449c1393583e (diff)
downloadlinux-a85999b9876543aa9b7a204ee2a660e1d1806262.tar.gz
linux-a85999b9876543aa9b7a204ee2a660e1d1806262.tar.bz2
linux-a85999b9876543aa9b7a204ee2a660e1d1806262.zip
HID: wacom: fix memory leak on kobject creation failure
commit 5ae416c5b1e2e816aee7b3fc8347adf70afabb4c upstream. 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: 83e6b40e2de6 ("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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/wacom_sys.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 64afaa243942..53517bcb6a35 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -2021,8 +2021,10 @@ static int wacom_initialize_remotes(struct wacom *wacom)
remote->remote_dir = kobject_create_and_add("wacom_remote",
&wacom->hdev->dev.kobj);
- if (!remote->remote_dir)
+ if (!remote->remote_dir) {
+ kfifo_free(&remote->remote_fifo);
return -ENOMEM;
+ }
error = sysfs_create_files(remote->remote_dir, remote_unpair_attrs);