Skip to contentSkip to conversation

tg3: Avoid NULL pointer dereference in netif_device_attach()

PATCH In review Defang Bo 2 participants 2 messages Oct 21, 2020

Subsystems (3)
lore
Share & tools
lore

Defang Bo

author
#0 lore raw

PATCH v3 1/1 tg3: Avoid NULL pointer dereference in netif_device_attach()

Similar to commit<1b0ff89852d7>("tg3: Avoid NULL pointer dereference in tg3_io_error_detected()") This patch avoids NULL pointer dereference add a check for netdev being NULL on tg3_resume().

---
 drivers/net/ethernet/broadcom/tg3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/broadcom/tg3.c +1 -1
index ae756dd..345c6aa 100644
@@ -18099,7 +18099,7 @@ static int tg3_resume(struct device *device)
 
 	rtnl_lock();
 
-	if (!netdev || !netif_running(dev))
+	if (!dev || !netif_running(dev))
 		goto unlock;
 
 	netif_device_attach(dev);
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 4 lines · On Wed, 21 Oct 2020 15:38:09 +0800 Defang Bo wrote:

Similar to commit<1b0ff89852d7>("tg3: Avoid NULL pointer dereference in tg3_io_error_detected()") This patch avoids NULL pointer dereference add a check for netdev being NULL on tg3_resume().

Are you actually hitting this error or can otherwise prove it may happen?

PCIe error handlers could reasonably happen asynchronously during probe, but suspend/resume getting called on a device that wasn't fully probed sounds like something that should be prevented by the bus.

Quoted 13 lines
drivers/net/ethernet/broadcom/tg3.c +1 -1
index ae756dd..345c6aa 100644
@@ -18099,7 +18099,7 @@ static int tg3_resume(struct device *device)
 
 	rtnl_lock();
 
-	if (!netdev || !netif_running(dev))
+	if (!dev || !netif_running(dev))
 		goto unlock;
 
 	netif_device_attach(dev);