Skip to contentSkip to conversation

netpoll: don't dereference NULL dev from np

PATCH Applied Pavel Emelyanov 2 participants 2 messages May 11, 2009 – May 18, 2009

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

PATCH 1/1 netpoll: don't dereference NULL dev from np

It looks like the dev in netpoll_poll can be NULL - at lease it's checked at the function beginning. Thus the dev->netde_ops dereference looks dangerous.

---

net/core/netpoll.c +6 -2
index b5873bd..64f51ee 100644
@@ -175,9 +175,13 @@ static void service_arp_queue(struct netpoll_info *npi)
 void netpoll_poll(struct netpoll *np)
 {
 	struct net_device *dev = np->dev;
-	const struct net_device_ops *ops = dev->netdev_ops;
+	const struct net_device_ops *ops;
+
+	if (!dev || !netif_running(dev))
+		return;
 
-	if (!dev || !netif_running(dev) || !ops->ndo_poll_controller)
+	ops = dev->netdev_ops;
+	if (!ops->ndo_poll_controller)
 		return;
 
 	/* Process pending work on NIC */
maintainer Applied
#1 lore raw

From: Pavel Emelyanov <[email protected]>
Date: Mon, 11 May 2009 14:36:35 +0400

Quoted 5 lines

It looks like the dev in netpoll_poll can be NULL - at lease it's checked at the function beginning. Thus the dev->netde_ops dereference looks dangerous.

Good catch, probably added by the netdev_ops changes.

Applied, thanks!