linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* pull-request: can 2021-07-30
@ 2021-07-30  7:05 Marc Kleine-Budde
  2021-07-30  7:05 ` [PATCH net 1/6] MAINTAINERS: add Yasushi SHOJI as reviewer for the Microchip CAN BUS Analyzer Tool driver Marc Kleine-Budde
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2021-07-30  7:05 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel

Hello Jakub, hello David,

this is a pull request of 6 patches for net/master.

The first patch is by me and adds Yasushi SHOJI as a reviewer for the
Microchip CAN BUS Analyzer Tool driver.

Dan Carpenter's patch fixes a signedness bug in the hi311x driver.

Pavel Skripkin provides 4 patches, the first targets the mcba_usb
driver by adding the missing urb->transfer_dma initialization, which
was broken in a previous commit. The last 3 patches fix a memory leak
in the usb_8dev, ems_usb and esd_usb2 driver.

regards,
Marc

---

The following changes since commit fc16a5322ee6c30ea848818722eee5d352f8d127:

  Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf (2021-07-29 00:53:32 +0100)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git tags/linux-can-fixes-for-5.14-20210730

for you to fetch changes up to 928150fad41ba16df7fcc9f7f945747d0f56cbb6:

  can: esd_usb2: fix memory leak (2021-07-30 08:47:34 +0200)

----------------------------------------------------------------
linux-can-fixes-for-5.14-20210730

----------------------------------------------------------------
Dan Carpenter (1):
      can: hi311x: fix a signedness bug in hi3110_cmd()

Marc Kleine-Budde (1):
      MAINTAINERS: add Yasushi SHOJI as reviewer for the Microchip CAN BUS Analyzer Tool driver

Pavel Skripkin (4):
      can: mcba_usb_start(): add missing urb->transfer_dma initialization
      can: usb_8dev: fix memory leak
      can: ems_usb: fix memory leak
      can: esd_usb2: fix memory leak

 MAINTAINERS                    |  6 ++++++
 drivers/net/can/spi/hi311x.c   |  2 +-
 drivers/net/can/usb/ems_usb.c  | 14 +++++++++++++-
 drivers/net/can/usb/esd_usb2.c | 16 +++++++++++++++-
 drivers/net/can/usb/mcba_usb.c |  2 ++
 drivers/net/can/usb/usb_8dev.c | 15 +++++++++++++--
 6 files changed, 50 insertions(+), 5 deletions(-)



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH net 1/6] MAINTAINERS: add Yasushi SHOJI as reviewer for the Microchip CAN BUS Analyzer Tool driver
  2021-07-30  7:05 pull-request: can 2021-07-30 Marc Kleine-Budde
@ 2021-07-30  7:05 ` Marc Kleine-Budde
  2021-07-30  7:05 ` [PATCH net 2/6] can: hi311x: fix a signedness bug in hi3110_cmd() Marc Kleine-Budde
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2021-07-30  7:05 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Marc Kleine-Budde, Yasushi SHOJI

This patch adds Yasushi SHOJI as a reviewer for the Microchip CAN BUS
Analyzer Tool driver.

Link: https://lore.kernel.org/r/20210726111619.1023991-1-mkl@pengutronix.de
Acked-by: Yasushi SHOJI <yashi@spacecubics.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 58afeb12d3b3..42ea3183e87c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11327,6 +11327,12 @@ W:	https://linuxtv.org
 T:	git git://linuxtv.org/media_tree.git
 F:	drivers/media/radio/radio-maxiradio*
 
+MCAB MICROCHIP CAN BUS ANALYZER TOOL DRIVER
+R:	Yasushi SHOJI <yashi@spacecubics.com>
+L:	linux-can@vger.kernel.org
+S:	Maintained
+F:	drivers/net/can/usb/mcba_usb.c
+
 MCAN MMIO DEVICE DRIVER
 M:	Chandrasekar Ramakrishnan <rcsekar@samsung.com>
 L:	linux-can@vger.kernel.org

base-commit: fc16a5322ee6c30ea848818722eee5d352f8d127
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net 2/6] can: hi311x: fix a signedness bug in hi3110_cmd()
  2021-07-30  7:05 pull-request: can 2021-07-30 Marc Kleine-Budde
  2021-07-30  7:05 ` [PATCH net 1/6] MAINTAINERS: add Yasushi SHOJI as reviewer for the Microchip CAN BUS Analyzer Tool driver Marc Kleine-Budde
@ 2021-07-30  7:05 ` Marc Kleine-Budde
  2021-07-30  7:05 ` [PATCH net 3/6] can: mcba_usb_start(): add missing urb->transfer_dma initialization Marc Kleine-Budde
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2021-07-30  7:05 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Dan Carpenter, Marc Kleine-Budde

From: Dan Carpenter <dan.carpenter@oracle.com>

The hi3110_cmd() is supposed to return zero on success and negative
error codes on failure, but it was accidentally declared as a u8 when
it needs to be an int type.

Fixes: 57e83fb9b746 ("can: hi311x: Add Holt HI-311x CAN driver")
Link: https://lore.kernel.org/r/20210729141246.GA1267@kili
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/spi/hi311x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/spi/hi311x.c b/drivers/net/can/spi/hi311x.c
index dd17b8c53e1c..89d9c986a229 100644
--- a/drivers/net/can/spi/hi311x.c
+++ b/drivers/net/can/spi/hi311x.c
@@ -218,7 +218,7 @@ static int hi3110_spi_trans(struct spi_device *spi, int len)
 	return ret;
 }
 
-static u8 hi3110_cmd(struct spi_device *spi, u8 command)
+static int hi3110_cmd(struct spi_device *spi, u8 command)
 {
 	struct hi3110_priv *priv = spi_get_drvdata(spi);
 
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net 3/6] can: mcba_usb_start(): add missing urb->transfer_dma initialization
  2021-07-30  7:05 pull-request: can 2021-07-30 Marc Kleine-Budde
  2021-07-30  7:05 ` [PATCH net 1/6] MAINTAINERS: add Yasushi SHOJI as reviewer for the Microchip CAN BUS Analyzer Tool driver Marc Kleine-Budde
  2021-07-30  7:05 ` [PATCH net 2/6] can: hi311x: fix a signedness bug in hi3110_cmd() Marc Kleine-Budde
@ 2021-07-30  7:05 ` Marc Kleine-Budde
  2021-07-30  7:05 ` [PATCH net 4/6] can: usb_8dev: fix memory leak Marc Kleine-Budde
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2021-07-30  7:05 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Pavel Skripkin, linux-stable,
	Yasushi SHOJI, Yasushi SHOJI, Marc Kleine-Budde

From: Pavel Skripkin <paskripkin@gmail.com>

Yasushi reported, that his Microchip CAN Analyzer stopped working
since commit 91c02557174b ("can: mcba_usb: fix memory leak in
mcba_usb"). The problem was in missing urb->transfer_dma
initialization.

In my previous patch to this driver I refactored mcba_usb_start() code
to avoid leaking usb coherent buffers. To archive it, I passed local
stack variable to usb_alloc_coherent() and then saved it to private
array to correctly free all coherent buffers on ->close() call. But I
forgot to initialize urb->transfer_dma with variable passed to
usb_alloc_coherent().

All of this was causing device to not work, since dma addr 0 is not
valid and following log can be found on bug report page, which points
exactly to problem described above.

| DMAR: [DMA Write] Request device [00:14.0] PASID ffffffff fault addr 0 [fault reason 05] PTE Write access is not set

Fixes: 91c02557174b ("can: mcba_usb: fix memory leak in mcba_usb")
Link: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=990850
Link: https://lore.kernel.org/r/20210725103630.23864-1-paskripkin@gmail.com
Cc: linux-stable <stable@vger.kernel.org>
Reported-by: Yasushi SHOJI <yasushi.shoji@gmail.com>
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Tested-by: Yasushi SHOJI <yashi@spacecubics.com>
[mkl: fixed typos in commit message - thanks Yasushi SHOJI]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/mcba_usb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/can/usb/mcba_usb.c b/drivers/net/can/usb/mcba_usb.c
index a45865bd7254..a1a154c08b7f 100644
--- a/drivers/net/can/usb/mcba_usb.c
+++ b/drivers/net/can/usb/mcba_usb.c
@@ -653,6 +653,8 @@ static int mcba_usb_start(struct mcba_priv *priv)
 			break;
 		}
 
+		urb->transfer_dma = buf_dma;
+
 		usb_fill_bulk_urb(urb, priv->udev,
 				  usb_rcvbulkpipe(priv->udev, MCBA_USB_EP_IN),
 				  buf, MCBA_USB_RX_BUFF_SIZE,
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net 4/6] can: usb_8dev: fix memory leak
  2021-07-30  7:05 pull-request: can 2021-07-30 Marc Kleine-Budde
                   ` (2 preceding siblings ...)
  2021-07-30  7:05 ` [PATCH net 3/6] can: mcba_usb_start(): add missing urb->transfer_dma initialization Marc Kleine-Budde
@ 2021-07-30  7:05 ` Marc Kleine-Budde
  2021-07-30 17:32   ` Jakub Kicinski
  2021-07-30  7:05 ` [PATCH net 5/6] can: ems_usb: " Marc Kleine-Budde
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 9+ messages in thread
From: Marc Kleine-Budde @ 2021-07-30  7:05 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Pavel Skripkin, linux-stable,
	Marc Kleine-Budde

From: Pavel Skripkin <paskripkin@gmail.com>

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 | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/usb/usb_8dev.c b/drivers/net/can/usb/usb_8dev.c
index b6e7ef0d5bc6..d1b83bd1b3cb 100644
--- a/drivers/net/can/usb/usb_8dev.c
+++ b/drivers/net/can/usb/usb_8dev.c
@@ -137,7 +137,8 @@ struct usb_8dev_priv {
 	u8 *cmd_msg_buffer;
 
 	struct mutex usb_8dev_cmd_lock;
-
+	void *rxbuf[MAX_RX_URBS];
+	dma_addr_t rxbuf_dma[MAX_RX_URBS];
 };
 
 /* tx frame */
@@ -733,6 +734,7 @@ static int usb_8dev_start(struct usb_8dev_priv *priv)
 	for (i = 0; i < MAX_RX_URBS; i++) {
 		struct urb *urb = NULL;
 		u8 *buf;
+		dma_addr_t buf_dma;
 
 		/* create a URB, and a buffer for it */
 		urb = usb_alloc_urb(0, GFP_KERNEL);
@@ -742,7 +744,7 @@ static int usb_8dev_start(struct usb_8dev_priv *priv)
 		}
 
 		buf = usb_alloc_coherent(priv->udev, RX_BUFFER_SIZE, GFP_KERNEL,
-					 &urb->transfer_dma);
+					 &buf_dma);
 		if (!buf) {
 			netdev_err(netdev, "No memory left for USB buffer\n");
 			usb_free_urb(urb);
@@ -750,6 +752,8 @@ static int usb_8dev_start(struct usb_8dev_priv *priv)
 			break;
 		}
 
+		urb->transfer_dma = buf_dma;
+
 		usb_fill_bulk_urb(urb, priv->udev,
 				  usb_rcvbulkpipe(priv->udev,
 						  USB_8DEV_ENDP_DATA_RX),
@@ -767,6 +771,9 @@ static int usb_8dev_start(struct usb_8dev_priv *priv)
 			break;
 		}
 
+		priv->rxbuf[i] = buf;
+		priv->rxbuf_dma[i] = buf_dma;
+
 		/* Drop reference, USB core will take care of freeing it */
 		usb_free_urb(urb);
 	}
@@ -836,6 +843,10 @@ static void unlink_all_urbs(struct usb_8dev_priv *priv)
 
 	usb_kill_anchored_urbs(&priv->rx_submitted);
 
+	for (i = 0; i < MAX_RX_URBS; ++i)
+		usb_free_coherent(priv->udev, RX_BUFFER_SIZE,
+				  priv->rxbuf[i], priv->rxbuf_dma[i]);
+
 	usb_kill_anchored_urbs(&priv->tx_submitted);
 	atomic_set(&priv->active_tx_urbs, 0);
 
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net 5/6] can: ems_usb: fix memory leak
  2021-07-30  7:05 pull-request: can 2021-07-30 Marc Kleine-Budde
                   ` (3 preceding siblings ...)
  2021-07-30  7:05 ` [PATCH net 4/6] can: usb_8dev: fix memory leak Marc Kleine-Budde
@ 2021-07-30  7:05 ` Marc Kleine-Budde
  2021-07-30  7:05 ` [PATCH net 6/6] can: esd_usb2: " Marc Kleine-Budde
  2021-07-30 17:33 ` pull-request: can 2021-07-30 Jakub Kicinski
  6 siblings, 0 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2021-07-30  7:05 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Pavel Skripkin, linux-stable,
	Marc Kleine-Budde

From: Pavel Skripkin <paskripkin@gmail.com>

In ems_usb_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 ems_usb_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: 702171adeed3 ("ems_usb: Added support for EMS CPC-USB/ARM7 CAN/USB interface")
Link: https://lore.kernel.org/r/59aa9fbc9a8cbf9af2bbd2f61a659c480b415800.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/ems_usb.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
index 0a37af4a3fa4..2b5302e72435 100644
--- a/drivers/net/can/usb/ems_usb.c
+++ b/drivers/net/can/usb/ems_usb.c
@@ -255,6 +255,8 @@ struct ems_usb {
 	unsigned int free_slots; /* remember number of available slots */
 
 	struct ems_cpc_msg active_params; /* active controller parameters */
+	void *rxbuf[MAX_RX_URBS];
+	dma_addr_t rxbuf_dma[MAX_RX_URBS];
 };
 
 static void ems_usb_read_interrupt_callback(struct urb *urb)
@@ -587,6 +589,7 @@ static int ems_usb_start(struct ems_usb *dev)
 	for (i = 0; i < MAX_RX_URBS; i++) {
 		struct urb *urb = NULL;
 		u8 *buf = NULL;
+		dma_addr_t buf_dma;
 
 		/* create a URB, and a buffer for it */
 		urb = usb_alloc_urb(0, GFP_KERNEL);
@@ -596,7 +599,7 @@ static int ems_usb_start(struct ems_usb *dev)
 		}
 
 		buf = usb_alloc_coherent(dev->udev, RX_BUFFER_SIZE, GFP_KERNEL,
-					 &urb->transfer_dma);
+					 &buf_dma);
 		if (!buf) {
 			netdev_err(netdev, "No memory left for USB buffer\n");
 			usb_free_urb(urb);
@@ -604,6 +607,8 @@ static int ems_usb_start(struct ems_usb *dev)
 			break;
 		}
 
+		urb->transfer_dma = buf_dma;
+
 		usb_fill_bulk_urb(urb, dev->udev, usb_rcvbulkpipe(dev->udev, 2),
 				  buf, RX_BUFFER_SIZE,
 				  ems_usb_read_bulk_callback, dev);
@@ -619,6 +624,9 @@ static int ems_usb_start(struct ems_usb *dev)
 			break;
 		}
 
+		dev->rxbuf[i] = buf;
+		dev->rxbuf_dma[i] = buf_dma;
+
 		/* Drop reference, USB core will take care of freeing it */
 		usb_free_urb(urb);
 	}
@@ -684,6 +692,10 @@ static void unlink_all_urbs(struct ems_usb *dev)
 
 	usb_kill_anchored_urbs(&dev->rx_submitted);
 
+	for (i = 0; i < MAX_RX_URBS; ++i)
+		usb_free_coherent(dev->udev, RX_BUFFER_SIZE,
+				  dev->rxbuf[i], dev->rxbuf_dma[i]);
+
 	usb_kill_anchored_urbs(&dev->tx_submitted);
 	atomic_set(&dev->active_tx_urbs, 0);
 
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net 6/6] can: esd_usb2: fix memory leak
  2021-07-30  7:05 pull-request: can 2021-07-30 Marc Kleine-Budde
                   ` (4 preceding siblings ...)
  2021-07-30  7:05 ` [PATCH net 5/6] can: ems_usb: " Marc Kleine-Budde
@ 2021-07-30  7:05 ` Marc Kleine-Budde
  2021-07-30 17:33 ` pull-request: can 2021-07-30 Jakub Kicinski
  6 siblings, 0 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2021-07-30  7:05 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Pavel Skripkin, linux-stable,
	Marc Kleine-Budde

From: Pavel Skripkin <paskripkin@gmail.com>

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>
---
 drivers/net/can/usb/esd_usb2.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/usb/esd_usb2.c b/drivers/net/can/usb/esd_usb2.c
index 65b58f8fc328..66fa8b07c2e6 100644
--- a/drivers/net/can/usb/esd_usb2.c
+++ b/drivers/net/can/usb/esd_usb2.c
@@ -195,6 +195,8 @@ struct esd_usb2 {
 	int net_count;
 	u32 version;
 	int rxinitdone;
+	void *rxbuf[MAX_RX_URBS];
+	dma_addr_t rxbuf_dma[MAX_RX_URBS];
 };
 
 struct esd_usb2_net_priv {
@@ -545,6 +547,7 @@ static int esd_usb2_setup_rx_urbs(struct esd_usb2 *dev)
 	for (i = 0; i < MAX_RX_URBS; i++) {
 		struct urb *urb = NULL;
 		u8 *buf = NULL;
+		dma_addr_t buf_dma;
 
 		/* create a URB, and a buffer for it */
 		urb = usb_alloc_urb(0, GFP_KERNEL);
@@ -554,7 +557,7 @@ static int esd_usb2_setup_rx_urbs(struct esd_usb2 *dev)
 		}
 
 		buf = usb_alloc_coherent(dev->udev, RX_BUFFER_SIZE, GFP_KERNEL,
-					 &urb->transfer_dma);
+					 &buf_dma);
 		if (!buf) {
 			dev_warn(dev->udev->dev.parent,
 				 "No memory left for USB buffer\n");
@@ -562,6 +565,8 @@ static int esd_usb2_setup_rx_urbs(struct esd_usb2 *dev)
 			goto freeurb;
 		}
 
+		urb->transfer_dma = buf_dma;
+
 		usb_fill_bulk_urb(urb, dev->udev,
 				  usb_rcvbulkpipe(dev->udev, 1),
 				  buf, RX_BUFFER_SIZE,
@@ -574,8 +579,12 @@ static int esd_usb2_setup_rx_urbs(struct esd_usb2 *dev)
 			usb_unanchor_urb(urb);
 			usb_free_coherent(dev->udev, RX_BUFFER_SIZE, buf,
 					  urb->transfer_dma);
+			goto freeurb;
 		}
 
+		dev->rxbuf[i] = buf;
+		dev->rxbuf_dma[i] = buf_dma;
+
 freeurb:
 		/* Drop reference, USB core will take care of freeing it */
 		usb_free_urb(urb);
@@ -663,6 +672,11 @@ static void unlink_all_urbs(struct esd_usb2 *dev)
 	int i, j;
 
 	usb_kill_anchored_urbs(&dev->rx_submitted);
+
+	for (i = 0; i < MAX_RX_URBS; ++i)
+		usb_free_coherent(dev->udev, RX_BUFFER_SIZE,
+				  dev->rxbuf[i], dev->rxbuf_dma[i]);
+
 	for (i = 0; i < dev->net_count; i++) {
 		priv = dev->nets[i];
 		if (priv) {
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH net 4/6] can: usb_8dev: fix memory leak
  2021-07-30  7:05 ` [PATCH net 4/6] can: usb_8dev: fix memory leak Marc Kleine-Budde
@ 2021-07-30 17:32   ` Jakub Kicinski
  0 siblings, 0 replies; 9+ messages in thread
From: Jakub Kicinski @ 2021-07-30 17:32 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: netdev, davem, linux-can, kernel, Pavel Skripkin, linux-stable

On Fri, 30 Jul 2021 09:05:24 +0200 Marc Kleine-Budde wrote:
> Cc: linux-stable <stable@vger.kernel.org>

nit: checkpatch complained about this format of CCing stable

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: pull-request: can 2021-07-30
  2021-07-30  7:05 pull-request: can 2021-07-30 Marc Kleine-Budde
                   ` (5 preceding siblings ...)
  2021-07-30  7:05 ` [PATCH net 6/6] can: esd_usb2: " Marc Kleine-Budde
@ 2021-07-30 17:33 ` Jakub Kicinski
  6 siblings, 0 replies; 9+ messages in thread
From: Jakub Kicinski @ 2021-07-30 17:33 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: netdev, davem, linux-can, kernel

On Fri, 30 Jul 2021 09:05:20 +0200 Marc Kleine-Budde wrote:
> The first patch is by me and adds Yasushi SHOJI as a reviewer for the
> Microchip CAN BUS Analyzer Tool driver.
> 
> Dan Carpenter's patch fixes a signedness bug in the hi311x driver.
> 
> Pavel Skripkin provides 4 patches, the first targets the mcba_usb
> driver by adding the missing urb->transfer_dma initialization, which
> was broken in a previous commit. The last 3 patches fix a memory leak
> in the usb_8dev, ems_usb and esd_usb2 driver.

Pulled, thank you!

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-07-30 17:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-30  7:05 pull-request: can 2021-07-30 Marc Kleine-Budde
2021-07-30  7:05 ` [PATCH net 1/6] MAINTAINERS: add Yasushi SHOJI as reviewer for the Microchip CAN BUS Analyzer Tool driver Marc Kleine-Budde
2021-07-30  7:05 ` [PATCH net 2/6] can: hi311x: fix a signedness bug in hi3110_cmd() Marc Kleine-Budde
2021-07-30  7:05 ` [PATCH net 3/6] can: mcba_usb_start(): add missing urb->transfer_dma initialization Marc Kleine-Budde
2021-07-30  7:05 ` [PATCH net 4/6] can: usb_8dev: fix memory leak Marc Kleine-Budde
2021-07-30 17:32   ` Jakub Kicinski
2021-07-30  7:05 ` [PATCH net 5/6] can: ems_usb: " Marc Kleine-Budde
2021-07-30  7:05 ` [PATCH net 6/6] can: esd_usb2: " Marc Kleine-Budde
2021-07-30 17:33 ` pull-request: can 2021-07-30 Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).