Wang Hai
f05fe15e90
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: bad41a5bf1 ("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-26 11:58:36 +01:00
..
2021-09-03 09:43:07 +02:00
2021-10-06 10:22:23 +02:00
2020-11-10 10:22:20 +01:00
2020-07-22 09:10:06 +02:00
2020-07-22 09:10:06 +02:00
2021-01-09 13:34:15 +01:00
2021-08-15 12:59:55 +02:00
2021-08-15 12:59:55 +02:00
2020-05-20 08:11:34 +02:00
2019-05-16 19:45:16 +02:00
2021-03-17 16:07:21 +01:00
2018-09-26 08:35:08 +02:00
2020-02-05 13:03:31 +00:00
2021-01-12 19:47:56 +01:00
2021-01-12 19:47:57 +01:00
2021-11-26 11:58:36 +01:00
2020-12-11 13:36:44 +01:00
2018-10-10 08:52:04 +02:00
2021-09-22 11:41:18 +02:00
2021-10-06 10:22:23 +02:00
2021-06-16 11:34:53 +02:00
2020-01-23 08:18:38 +01:00
2021-10-27 09:32:38 +02:00
2021-06-03 08:22:06 +02:00
2021-06-03 08:22:06 +02:00
2021-10-27 09:32:38 +02:00
2021-06-16 11:34:53 +02:00
2018-08-22 07:48:37 +02:00
2019-10-29 09:13:24 +01:00
2018-09-26 08:35:10 +02:00
2020-06-11 09:21:39 +02:00
2020-01-23 08:18:38 +01:00
2020-01-23 08:18:38 +01:00
2020-01-14 20:03:04 +01:00
2018-05-16 10:06:49 +02:00
2019-11-06 12:09:20 +01:00
2019-11-06 12:09:20 +01:00