[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1565804493-7758-1-git-send-email-wenwen@cs.uga.edu>
Date: Wed, 14 Aug 2019 12:41:33 -0500
From: Wenwen Wang <wenwen@...uga.edu>
To: Wenwen Wang <wenwen@...uga.edu>
Cc: Oliver Neukum <oneukum@...e.com>,
"David S. Miller" <davem@...emloft.net>,
netdev@...r.kernel.org (open list:USB "USBNET" DRIVER FRAMEWORK),
linux-usb@...r.kernel.org (open list:USB NETWORKING DRIVERS),
linux-kernel@...r.kernel.org (open list)
Subject: [PATCH] net: usbnet: fix a memory leak bug
In usbnet_start_xmit(), 'urb->sg' is allocated through kmalloc_array() by
invoking build_dma_sg(). Later on, if 'CONFIG_PM' is defined and the if
branch is taken, the execution will go to the label 'deferred'. However,
'urb->sg' is not deallocated on this execution path, leading to a memory
leak bug.
Signed-off-by: Wenwen Wang <wenwen@...uga.edu>
---
drivers/net/usb/usbnet.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 72514c4..f17fafa 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1433,6 +1433,7 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
usb_anchor_urb(urb, &dev->deferred);
/* no use to process more packets */
netif_stop_queue(net);
+ kfree(urb->sg);
usb_put_urb(urb);
spin_unlock_irqrestore(&dev->txq.lock, flags);
netdev_dbg(dev->net, "Delaying transmission for resumption\n");
--
2.7.4
Powered by blists - more mailing lists