can: usb_8dev: fix memory leak
authorPavel Skripkin <paskripkin@gmail.com>
Tue, 27 Jul 2021 16:59:57 +0000 (19:59 +0300)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Fri, 30 Jul 2021 06:47:05 +0000 (08:47 +0200)
commit0e865f0c31928d6a313269ef624907eec55287c4
treee1677349b9c6038000af3eea20022d19f69fef98
parentfc43fb69a7af92839551f99c1a96a37b77b3ae7a
can: usb_8dev: fix memory leak

In usb_8dev_start() 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 usb_8dev_start) 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: 0024d8ad1639 ("can: usb_8dev: Add support for USB2CAN interface from 8 devices")
Link: https://lore.kernel.org/r/d39b458cd425a1cf7f512f340224e6e9563b07bd.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>
drivers/net/can/usb/usb_8dev.c