]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
can: esd_usb2: fix memory leak
authorPavel Skripkin <paskripkin@gmail.com>
Tue, 27 Jul 2021 17:00:46 +0000 (20:00 +0300)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 20 Sep 2021 13:42:18 +0000 (15:42 +0200)
commit3acd9ef8e1269501e10631fbd0b37f98e5376ee7
tree93e5b5a977674e8bcde15c2a5158bdb935d1c2ed
parente5343ac88e5c47f08208dc693cf30f183ef9bb52
can: esd_usb2: fix memory leak

BugLink: https://bugs.launchpad.net/bugs/1940706
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: 96d8e90382dc ("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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
drivers/net/can/usb/esd_usb2.c