Kuen-Han Tsai
e4f5ce9908
usb: gadget: f_eem: Fix memory leak in eem_unwrap
The existing code did not handle the failure case of usb_ep_queue in the
command path, potentially leading to memory leaks.
Improve error handling to free all allocated resources on usb_ep_queue
failure. This patch continues to use goto logic for error handling, as the
existing error handling is complex and not easily adaptable to auto-cleanup
helpers.
kmemleak results:
unreferenced object 0xffffff895a512300 (size 240):
backtrace:
slab_post_alloc_hook+0xbc/0x3a4
kmem_cache_alloc+0x1b4/0x358
skb_clone+0x90/0xd8
eem_unwrap+0x1cc/0x36c
unreferenced object 0xffffff8a157f4000 (size 256):
backtrace:
slab_post_alloc_hook+0xbc/0x3a4
__kmem_cache_alloc_node+0x1b4/0x2dc
kmalloc_trace+0x48/0x140
dwc3_gadget_ep_alloc_request+0x58/0x11c
usb_ep_alloc_request+0x40/0xe4
eem_unwrap+0x204/0x36c
unreferenced object 0xffffff8aadbaac00 (size 128):
backtrace:
slab_post_alloc_hook+0xbc/0x3a4
__kmem_cache_alloc_node+0x1b4/0x2dc
__kmalloc+0x64/0x1a8
eem_unwrap+0x218/0x36c
unreferenced object 0xffffff89ccef3500 (size 64):
backtrace:
slab_post_alloc_hook+0xbc/0x3a4
__kmem_cache_alloc_node+0x1b4/0x2dc
kmalloc_trace+0x48/0x140
eem_unwrap+0x238/0x36c
Fixes: 4249d6fbc1 ("usb: gadget: eem: fix echo command packet response issue")
Cc: stable@kernel.org
Signed-off-by: Kuen-Han Tsai <khtsai@google.com>
Link: https://patch.msgid.link/20251103121814.1559719-1-khtsai@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-11-09 11:11:19 +09:00
..
2025-10-14 08:56:31 -06:00
2025-10-25 09:35:26 -07:00
2025-10-22 08:04:15 +02:00
2025-10-13 09:12:36 +02:00
2025-10-22 08:06:28 +02:00
2025-10-24 12:48:19 -07:00
2025-09-27 11:37:02 -04:00
2025-10-04 16:26:32 -07:00
2025-10-04 16:26:32 -07:00
2025-10-18 14:33:22 +03:00
2025-10-07 09:28:37 -07:00
2025-10-07 08:40:15 -07:00
2025-10-22 08:03:52 +02:00
2025-10-15 08:21:16 -05:00
2025-10-20 21:27:16 +02:00
2025-10-08 09:38:31 -07:00
2025-10-14 14:48:14 -07:00
2025-10-15 10:39:54 -04:00
2025-09-26 15:10:59 -07:00
2025-10-06 10:37:06 -07:00
2025-10-13 17:24:36 -07:00
2025-09-30 11:41:03 -07:00
2025-10-25 08:29:56 +09:00
2025-10-23 22:30:01 +02:00
2025-09-22 10:33:10 -03:00
2025-10-23 14:30:11 +02:00
2025-10-24 13:39:21 +02:00
2025-10-18 08:18:18 -10:00
2025-10-01 00:00:45 +00:00
2025-10-19 18:56:14 -07:00
2025-10-04 16:26:32 -07:00
2025-10-14 13:54:43 +02:00
2025-09-29 00:17:22 +02:00
2025-09-23 14:15:25 +02:00
2025-10-03 18:35:22 -07:00
2025-10-08 09:44:38 -07:00
2025-10-03 18:18:48 -07:00
2025-10-07 10:23:22 +02:00
2025-09-16 16:49:28 +01:00
2025-10-08 11:44:21 -07:00
2025-10-03 18:48:02 -07:00
2025-10-04 16:07:08 -07:00
2025-10-02 18:18:33 -07:00
2025-10-03 10:38:23 -05:00
2025-10-26 10:33:46 -07:00
2025-10-13 13:18:03 +02:00
2025-10-22 08:04:43 +02:00
2025-10-04 15:50:37 -07:00
2025-10-23 07:14:33 -07:00
2025-09-22 09:35:21 -04:00
2025-10-06 11:17:18 -07:00
2025-10-16 11:32:04 -07:00
2025-10-22 08:02:38 +02:00
2025-10-24 07:44:09 -05:00
2025-10-24 16:43:08 -07:00
2025-10-07 08:59:25 -07:00
2025-10-06 10:34:22 -07:00
2025-10-06 10:41:03 -07:00
2025-10-15 11:22:35 +03:00
2025-10-01 17:32:51 -07:00
2025-10-01 13:02:59 -07:00
2025-10-22 19:18:39 -07:00
2025-10-01 11:34:12 -07:00
2025-10-01 12:04:12 -07:00
2025-10-04 15:45:17 -07:00
2025-10-01 17:32:51 -07:00
2025-09-20 21:29:48 -05:00
2025-10-11 11:56:47 -07:00
2025-10-09 10:51:43 -07:00
2025-10-13 15:54:13 -04:00
2025-10-05 10:09:55 -07:00
2025-10-06 10:32:22 -07:00
2025-10-20 16:15:31 +01:00
2025-10-13 10:55:03 +02:00
2025-10-11 11:49:00 -07:00
2025-10-17 15:26:52 +02:00
2025-10-02 10:41:58 +02:00
2025-10-20 08:20:34 +02:00
2025-10-22 12:13:54 +02:00
2025-10-11 11:49:00 -07:00
2025-10-07 08:40:15 -07:00
2025-11-09 11:11:19 +09:00
2025-10-01 07:24:55 -04:00
2025-10-06 11:22:48 -06:00
2025-10-01 07:24:43 -04:00
2025-10-10 09:36:23 -07:00
2025-09-29 18:48:39 -07:00
2025-10-04 08:48:16 -07:00
2025-10-06 11:00:30 -07:00
2025-10-03 17:41:12 -07:00
2025-10-07 08:40:15 -07:00