]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
HID: wacom: fix memory leak on kobject creation failure
authorQasim Ijaz <qasdev00@gmail.com>
Fri, 6 Jun 2025 18:49:57 +0000 (19:49 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 6 Jul 2025 09:00:14 +0000 (11:00 +0200)
commit33acbeeb5ad6263ad0482f98c2bfa2cca2963dbd
treee202eaa1ade89e356e6f815960ee2407537f0326
parentf0ffc8076d39a81d8dc21bdb2b19810310f6a4f3
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>
drivers/hid/wacom_sys.c