linux-brain/drivers/net/can/usb
Pavel Skripkin e9e2ce00ae can: esd_usb2: fix memory leak
commit 928150fad41ba16df7fcc9f7f945747d0f56cbb6 upstream.

In esd_usb2_setup_rx_urbs() MAX_RX_URBS coherent buffers are allocated
and there is nothing, that frees them:

1) In callback function the urb is resubmitted and that's all
2) In disconnect function urbs are simply killed, but URB_FREE_BUFFER
   is not set (see esd_usb2_setup_rx_urbs) and this flag cannot be used
   with coherent buffers.

So, all allocated buffers should be freed with usb_free_coherent()
explicitly.

Side note: This code looks like a copy-paste of other can drivers. The
same patch was applied to mcba_usb driver and it works nice with real
hardware. There is no change in functionality, only clean-up code for
coherent buffers.

Fixes: 96d8e90382 ("can: Add driver for esd CAN-USB/2 device")
Link: https://lore.kernel.org/r/b31b096926dcb35998ad0271aac4b51770ca7cc8.1627404470.git.paskripkin@gmail.com
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-08-04 12:27:38 +02:00
..
kvaser_usb can: kvaser_usb: kvaser_usb_hydra: Fix KCAN bittiming limits 2020-11-24 13:29:17 +01:00
peak_usb drivers: net: fix memory leak in peak_usb_create_dev 2021-04-14 08:24:18 +02:00
Kconfig drivers: net: Fix Kconfig indentation 2019-09-26 08:56:17 +02:00
Makefile can: kvaser_usb: Split driver into kvaser_usb_core.c and kvaser_usb_leaf.c 2018-07-27 10:40:19 +02:00
ems_usb.c can: ems_usb: fix memory leak 2021-08-04 12:27:38 +02:00
esd_usb2.c can: esd_usb2: fix memory leak 2021-08-04 12:27:38 +02:00
gs_usb.c can: gs_usb: fix endianess problem with candleLight firmware 2020-12-02 08:49:53 +01:00
mcba_usb.c can: mcba_usb_start(): add missing urb->transfer_dma initialization 2021-08-04 12:27:38 +02:00
ucan.c can: ucan: fix non-atomic allocation in completion handler 2019-12-13 08:43:16 +01:00
usb_8dev.c can: usb_8dev: fix memory leak 2021-08-04 12:27:38 +02:00