netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* pull-request: can 2013-09-21
@ 2013-09-21 14:08 Marc Kleine-Budde
  2013-09-21 14:08 ` [PATCH] can: pcan_usb_core: fix memory leak on failure paths in peak_usb_start() Marc Kleine-Budde
  2013-09-27  6:08 ` pull-request: can 2013-09-21 David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Marc Kleine-Budde @ 2013-09-21 14:08 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel

Hello David,

here is a fixes for the v3.12 release cycle. Alexey Khoroshilov from the Linux
Driver Verification project submitted a patch that fixes a memory leak in the
failure paths of the peak USB driver.


regards,
Marc

---

The following changes since commit dcb30e659287a6b40dafed1362532da42ec27229:

  Merge tag 'arm64-stable' of git://git.kernel.org/pub/scm/linux/kernel/git/cmarinas/linux-aarch64 (2013-09-20 08:18:51 -0500)

are available in the git repository at:


  git://gitorious.org/linux-can/linux-can.git fixes-for-3.12

for you to fetch changes up to f37d6e701f2a3a04e66690397340a6417f6e053f:

  can: pcan_usb_core: fix memory leak on failure paths in peak_usb_start() (2013-09-20 20:58:21 +0200)

----------------------------------------------------------------
Alexey Khoroshilov (1):
      can: pcan_usb_core: fix memory leak on failure paths in peak_usb_start()

 drivers/net/can/usb/peak_usb/pcan_usb_core.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

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

* [PATCH] can: pcan_usb_core: fix memory leak on failure paths in peak_usb_start()
  2013-09-21 14:08 pull-request: can 2013-09-21 Marc Kleine-Budde
@ 2013-09-21 14:08 ` Marc Kleine-Budde
  2013-09-27  6:08 ` pull-request: can 2013-09-21 David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Marc Kleine-Budde @ 2013-09-21 14:08 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel, Alexey Khoroshilov, Marc Kleine-Budde

From: Alexey Khoroshilov <khoroshilov@ispras.ru>

Tx and rx urbs are not deallocated if something goes wrong in peak_usb_start().
The patch fixes error handling to deallocate all the resources.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Acked-by: Stephane Grosjean <s.grosjean@peak-system.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/peak_usb/pcan_usb_core.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
index a0f647f..0b7a4c3 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
@@ -463,7 +463,7 @@ static int peak_usb_start(struct peak_usb_device *dev)
 	if (i < PCAN_USB_MAX_TX_URBS) {
 		if (i == 0) {
 			netdev_err(netdev, "couldn't setup any tx URB\n");
-			return err;
+			goto err_tx;
 		}
 
 		netdev_warn(netdev, "tx performance may be slow\n");
@@ -472,7 +472,7 @@ static int peak_usb_start(struct peak_usb_device *dev)
 	if (dev->adapter->dev_start) {
 		err = dev->adapter->dev_start(dev);
 		if (err)
-			goto failed;
+			goto err_adapter;
 	}
 
 	dev->state |= PCAN_USB_STATE_STARTED;
@@ -481,19 +481,26 @@ static int peak_usb_start(struct peak_usb_device *dev)
 	if (dev->adapter->dev_set_bus) {
 		err = dev->adapter->dev_set_bus(dev, 1);
 		if (err)
-			goto failed;
+			goto err_adapter;
 	}
 
 	dev->can.state = CAN_STATE_ERROR_ACTIVE;
 
 	return 0;
 
-failed:
+err_adapter:
 	if (err == -ENODEV)
 		netif_device_detach(dev->netdev);
 
 	netdev_warn(netdev, "couldn't submit control: %d\n", err);
 
+	for (i = 0; i < PCAN_USB_MAX_TX_URBS; i++) {
+		usb_free_urb(dev->tx_contexts[i].urb);
+		dev->tx_contexts[i].urb = NULL;
+	}
+err_tx:
+	usb_kill_anchored_urbs(&dev->rx_submitted);
+
 	return err;
 }
 
-- 
1.8.4.rc3

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

* Re: pull-request: can 2013-09-21
  2013-09-21 14:08 pull-request: can 2013-09-21 Marc Kleine-Budde
  2013-09-21 14:08 ` [PATCH] can: pcan_usb_core: fix memory leak on failure paths in peak_usb_start() Marc Kleine-Budde
@ 2013-09-27  6:08 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2013-09-27  6:08 UTC (permalink / raw)
  To: mkl; +Cc: netdev, linux-can, kernel

From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: Sat, 21 Sep 2013 16:08:12 +0200

> here is a fixes for the v3.12 release cycle. Alexey Khoroshilov from the Linux
> Driver Verification project submitted a patch that fixes a memory leak in the
> failure paths of the peak USB driver.

Pulled, thanks.

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

end of thread, other threads:[~2013-09-27  6:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-21 14:08 pull-request: can 2013-09-21 Marc Kleine-Budde
2013-09-21 14:08 ` [PATCH] can: pcan_usb_core: fix memory leak on failure paths in peak_usb_start() Marc Kleine-Budde
2013-09-27  6:08 ` pull-request: can 2013-09-21 David Miller

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).