Wang Hai
cefb16b7b2
USB: serial: keyspan: fix memleak on probe errors
...
commit 910c996335c37552ee30fcb837375b808bb4f33b upstream.
I got memory leak as follows when doing fault injection test:
unreferenced object 0xffff888258228440 (size 64):
comm "kworker/7:2", pid 2005, jiffies 4294989509 (age 824.540s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff8167939c>] slab_post_alloc_hook+0x9c/0x490
[<ffffffff8167f627>] kmem_cache_alloc_trace+0x1f7/0x470
[<ffffffffa02ac0e4>] keyspan_port_probe+0xa4/0x5d0 [keyspan]
[<ffffffffa0294c07>] usb_serial_device_probe+0x97/0x1d0 [usbserial]
[<ffffffff82b50ca7>] really_probe+0x167/0x460
[<ffffffff82b51099>] __driver_probe_device+0xf9/0x180
[<ffffffff82b51173>] driver_probe_device+0x53/0x130
[<ffffffff82b516f5>] __device_attach_driver+0x105/0x130
[<ffffffff82b4cfe9>] bus_for_each_drv+0x129/0x190
[<ffffffff82b50a69>] __device_attach+0x1c9/0x270
[<ffffffff82b518d0>] device_initial_probe+0x20/0x30
[<ffffffff82b4f062>] bus_probe_device+0x142/0x160
[<ffffffff82b4a4e9>] device_add+0x829/0x1300
[<ffffffffa0295fda>] usb_serial_probe.cold+0xc9b/0x14ac [usbserial]
[<ffffffffa02266aa>] usb_probe_interface+0x1aa/0x3c0 [usbcore]
[<ffffffff82b50ca7>] really_probe+0x167/0x460
If keyspan_port_probe() fails to allocate memory for an out_buffer[i] or
in_buffer[i], the previously allocated memory for out_buffer or
in_buffer needs to be freed on the error handling path, otherwise a
memory leak will result.
Fixes: bad41a5bf177 ("USB: keyspan: fix port DMA-buffer allocations")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Link: https://lore.kernel.org/r/20211015085543.1203011-1-wanghai38@huawei.com
Cc: stable@vger.kernel.org # 3.12
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-11-18 19:16:07 +01:00
..
2020-07-09 09:20:17 +02:00
2021-04-08 09:46:02 +02:00
2021-06-15 14:03:27 +02:00
2020-04-22 09:26:47 +02:00
2021-07-21 11:53:42 +02:00
2021-08-25 09:13:33 +02:00
2020-07-02 10:38:45 +02:00
2021-09-24 09:31:10 +02:00
2021-05-19 10:56:40 +02:00
2021-08-26 09:38:27 +02:00
2020-06-23 09:56:17 +02:00
2021-05-21 15:46:25 +02:00
2021-04-13 18:19:28 +02:00
2021-04-08 09:46:02 +02:00
2021-08-05 09:47:25 +02:00
2021-09-01 20:10:40 +02:00
2020-07-01 14:04:04 +02:00
2021-08-26 09:38:27 +02:00
2021-05-19 10:56:41 +02:00
2020-04-22 09:26:47 +02:00
2021-07-30 17:15:39 +02:00
2021-04-08 09:50:04 +02:00
2020-04-22 09:26:47 +02:00
2021-08-26 09:38:27 +02:00
2021-04-13 18:23:34 +02:00
2020-04-22 09:26:47 +02:00
2021-08-26 09:38:27 +02:00
2021-05-19 10:56:40 +02:00
2021-08-26 09:38:27 +02:00
2020-04-22 09:26:47 +02:00
2021-01-21 10:49:37 +01:00
2021-02-09 13:13:58 +01:00
2021-11-18 19:16:07 +01:00
2021-02-09 13:13:58 +01:00
2021-05-19 10:56:40 +02:00
2021-01-21 10:49:37 +01:00
2021-02-09 13:13:58 +01:00
2020-04-22 09:26:47 +02:00
2021-05-21 15:46:25 +02:00
2021-05-21 15:46:15 +02:00
2021-09-20 11:19:55 +02:00
2021-01-18 14:26:14 +01:00
2021-05-25 08:59:17 +02:00
2021-05-19 10:56:41 +02:00
2021-10-07 09:55:13 +02:00
2021-05-19 10:56:41 +02:00
2020-04-22 09:26:47 +02:00
2021-08-30 09:21:55 +02:00
2021-05-10 11:15:23 +02:00
2021-10-07 15:39:06 +02:00
2021-06-24 12:54:28 +02:00
2021-08-26 09:38:27 +02:00
2021-02-09 13:13:58 +01:00
2021-04-08 09:46:02 +02:00
2021-02-09 13:13:58 +01:00
2021-06-24 12:54:28 +02:00
2021-04-09 17:55:21 +02:00
2021-05-19 10:56:41 +02:00
2020-01-13 15:04:35 +01:00
2021-07-27 12:17:21 +02:00
2021-05-19 10:56:41 +02:00
2020-04-22 09:26:47 +02:00
2021-06-15 14:03:27 +02:00
2020-04-22 09:26:47 +02:00
2021-04-13 18:36:39 +02:00