netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: usbnet: Fix potential NULL pointer dereference
@ 2023-11-01 12:35 Ren Mingshuai
  2023-11-01 12:55 ` Ren Mingshuai
  0 siblings, 1 reply; 8+ messages in thread
From: Ren Mingshuai @ 2023-11-01 12:35 UTC (permalink / raw)
  To: oneukum
  Cc: khlebnikov, davem, caowangbao, yanan, liaichun, netdev,
	linux-kernel

23ba07991dad said SKB can be NULL without describing the triggering
scenario. Always Check it before dereference to void potential NULL
pointer dereference.
Fix smatch warning:
drivers/net/usb/usbnet.c:1380 usbnet_start_xmit() error: we previously assumed 'skb' could be null (see line 1359)

Signed-off-by: Ren Mingshuai <renmingshuai@huawei.com>
---
 drivers/net/usb/usbnet.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 64a9a80b2309..386cb1a4ff03 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1374,6 +1374,11 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
 		}
 	}
 
+	if (!skb) {
+		netif_dbg(dev, tx_err, dev->net, "tx skb is NULL\n");
+		goto drop;
+	}
+
 	if (!(urb = usb_alloc_urb (0, GFP_ATOMIC))) {
 		netif_dbg(dev, tx_err, dev->net, "no urb\n");
 		goto drop;
-- 
2.33.0


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

end of thread, other threads:[~2023-11-06 12:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-01 12:35 [PATCH] net: usbnet: Fix potential NULL pointer dereference Ren Mingshuai
2023-11-01 12:55 ` Ren Mingshuai
2023-11-02  4:38   ` Jakub Kicinski
2023-11-02  9:06     ` Ren Mingshuai
2023-11-06 10:18       ` Oliver Neukum
2023-11-06 10:55         ` Bjørn Mork
2023-11-06 12:53           ` Oliver Neukum
2023-11-06 12:59       ` Oliver Neukum

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