Skip to contentSkip to conversation

net: caif: spi: fix potential NULL dereference

PATCH In review Vasiliy Kulikov 2 participants 2 messages Nov 18, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 4/4 net: caif: spi: fix potential NULL dereference

alloc_netdev() is not checked here for NULL return value. dev is check instead. It might lead to NULL dereference of ndev.

---
Compile tested.
Maybe dev is also must be checked here, but it looks like a trivial typo.

 drivers/net/caif/caif_spi.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/caif/caif_spi.c +2 -2
index 8b4cea5..20da199 100644
@@ -635,8 +635,8 @@ int cfspi_spi_probe(struct platform_device *pdev)
 
 	ndev = alloc_netdev(sizeof(struct cfspi),
 			"cfspi%d", cfspi_setup);
-	if (!dev)
-		return -ENODEV;
+	if (!ndev)
+		return -ENOMEM;
 
 	cfspi = netdev_priv(ndev);
 	netif_stop_queue(ndev);
Signature · 1 line
1.7.0.4
maintainer
#1 lore raw

From: Vasiliy Kulikov <[email protected]>
Date: Thu, 18 Nov 2010 21:17:05 +0300

Quoted 7 lines

alloc_netdev() is not checked here for NULL return value. dev is check instead. It might lead to NULL dereference of ndev.

---
Compile tested.
Maybe dev is also must be checked here, but it looks like a trivial typo.

Definitely looks correct to me, applied, thanks!