OrangePi_CM5/drivers/usb/serial
Wang Hai 5f31af4e78 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-18 14:03:51 +01:00
..
Kconfig
…
Makefile
…
Makefile-keyspan_pda_fw
…
aircable.c
…
ark3116.c
…
belkin_sa.c
…
belkin_sa.h
…
bus.c
…
ch341.c Revert "USB: serial: ch341: fix character loss at high transfer rates" 2021-09-03 10:09:22 +02:00
console.c
…
cp210x.c USB: serial: cp210x: fix dropped characters with CP2102 2021-09-30 10:11:08 +02:00
cyberjack.c USB: serial: cyberjack: fix write-URB completion race 2020-11-04 11:07:48 +01:00
cypress_m8.c
…
cypress_m8.h
…
digi_acceleport.c USB: serial: digi_acceleport: fix write-wakeup deadlocks 2020-12-30 11:54:12 +01:00
empeg.c
…
ezusb_convert.pl
…
f81232.c
…
f81534.c
…
ftdi_sio.c USB: serial: ftdi_sio: add device ID for Auto-M3 OP-COM v2 2021-08-12 13:22:09 +02:00
ftdi_sio.h
…
ftdi_sio_ids.h USB: serial: ftdi_sio: add device ID for Auto-M3 OP-COM v2 2021-08-12 13:22:09 +02:00
garmin_gps.c
…
generic.c
…
io_16654.h
…
io_edgeport.c USB: serial: io_edgeport: fix memory leak in edge_startup 2021-03-17 17:06:30 +01:00
io_edgeport.h
…
io_ionsp.h
…
io_ti.c
…
io_ti.h
…
io_usbvend.h
…
ipaq.c
…
ipw.c
…
ir-usb.c
…
iuu_phoenix.c USB: serial: iuu_phoenix: fix DMA from stack 2021-01-12 20:18:20 +01:00
iuu_phoenix.h
…
keyspan.c USB: serial: keyspan: fix memleak on probe errors 2021-11-18 14:03:51 +01:00
keyspan_pda.c USB: serial: keyspan_pda: remove unused variable 2021-01-12 20:18:22 +01:00
keyspan_usa26msg.h
…
keyspan_usa28msg.h
…
keyspan_usa49msg.h
…
keyspan_usa67msg.h
…
keyspan_usa90msg.h
…
kl5kusb105.c USB: serial: kl5kusb105: fix memleak on open 2020-12-04 12:02:57 +01:00
kl5kusb105.h
…
kobil_sct.c
…
kobil_sct.h
…
mct_u232.c
…
mct_u232.h
…
metro-usb.c
…
mos7720.c USB: serial: mos7720: improve OOM-handling in read_mos_reg() 2021-09-12 08:58:26 +02:00
mos7840.c USB: serial: mos7840: remove duplicated 0xac24 device ID 2021-09-30 10:11:00 +02:00
mxuport.c
…
navman.c
…
omninet.c USB: serial: omninet: add device id for Zyxel Omni 56K Plus 2021-06-16 12:01:42 +02:00
opticon.c
…
option.c USB: serial: option: add prod. id for Quectel EG91 2021-10-20 11:45:01 +02:00
oti6858.c
…
oti6858.h
…
pl2303.c USB: serial: pl2303: add device id for ADLINK ND-6530 GC 2021-06-03 09:00:35 +02:00
pl2303.h USB: serial: pl2303: add device id for ADLINK ND-6530 GC 2021-06-03 09:00:35 +02:00
qcaux.c
…
qcserial.c USB: serial: qcserial: add EM9191 QDL support 2021-10-20 11:45:00 +02:00
quatech2.c USB: serial: quatech2: fix control-request directions 2021-06-16 12:01:42 +02:00
safe_serial.c
…
sierra.c
…
spcp8x5.c
…
ssu100.c
…
symbolserial.c
…
ti_usb_3410_5052.c USB: serial: ti_usb_3410_5052: add startech.com device id 2021-06-03 09:00:34 +02:00
upd78f0730.c
…
usb-serial-simple.c
…
usb-serial.c
…
usb-wwan.h
…
usb_debug.c
…
usb_wwan.c USB: serial: usb_wwan: fix TIOCSSERIAL jiffies conversions 2021-05-14 09:49:55 +02:00
visor.c
…
visor.h
…
whiteheat.c
…
whiteheat.h
…
wishbone-serial.c
…
xsens_mt.c
…