linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: usb: fix possible use-after-free in smsc75xx_bind
@ 2021-06-14 15:37 Dongliang Mu
  2021-06-14 16:00 ` Pavel Skripkin
  2021-06-15  7:38 ` Greg KH
  0 siblings, 2 replies; 13+ messages in thread
From: Dongliang Mu @ 2021-06-14 15:37 UTC (permalink / raw)
  To: steve.glendinning, davem, kuba, paskripkin
  Cc: netdev, linux-usb, linux-kernel, Dongliang Mu

The commit 46a8b29c6306 ("net: usb: fix memory leak in smsc75xx_bind")
fails to clean up the work scheduled in smsc75xx_reset->
smsc75xx_set_multicast, which leads to use-after-free if the work is
scheduled to start after the deallocation. In addition, this patch also
removes one dangling pointer - dev->data[0].

This patch calls cancel_work_sync to cancel the schedule work and set
the dangling pointer to NULL.

Fixes: 46a8b29c6306 ("net: usb: fix memory leak in smsc75xx_bind")
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
---
 drivers/net/usb/smsc75xx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index b286993da67c..f81740fcc8d5 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -1504,7 +1504,10 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf)
 	return 0;
 
 err:
+	cancel_work_sync(&pdata->set_multicast);
 	kfree(pdata);
+	pdata = NULL;
+	dev->data[0] = 0;
 	return ret;
 }
 
-- 
2.25.1


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

end of thread, other threads:[~2021-06-16  2:17 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-14 15:37 [PATCH] net: usb: fix possible use-after-free in smsc75xx_bind Dongliang Mu
2021-06-14 16:00 ` Pavel Skripkin
2021-06-14 23:01   ` Dongliang Mu
2021-06-15 13:31     ` Pavel Skripkin
2021-06-16  2:16       ` Dongliang Mu
2021-06-15  7:38 ` Greg KH
2021-06-15  7:56   ` Dongliang Mu
2021-06-15  9:44     ` Greg KH
2021-06-15 10:10       ` Dongliang Mu
2021-06-15 10:24         ` Dongliang Mu
2021-06-15 11:12           ` Greg KH
2021-06-15 12:07             ` Dongliang Mu
2021-06-15 13:03               ` Greg KH

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