Skip to contentSkip to conversation

net/tg3: Fix kernel crash

DISCUSSION Dave Jones 1 participant 1 message Aug 6, 2013 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Dave Jones

author
#1 lore raw
In reply to a message not in the archive
Quoted 21 lines · Linux Kernel
Gitweb:     http://git.kernel.org/linus/;a=commit;h=d8af4dfd84329015e18ea3d83a84c46e92f21020
Commit:     d8af4dfd84329015e18ea3d83a84c46e92f21020
Parent:     d738ce8fdc05ebf5b1475f8ae26d908c8c50970b
Author:     Gavin Shan <[email protected]>
AuthorDate: Wed Jul 24 17:25:08 2013 +0800

net/tg3: Fix kernel crash

While EEH error happens, we might not have network device instance (struct net_device) yet. So we can't access the instance safely and check its link state, which causes kernel crash. The patch fixes it.

drivers/net/ethernet/broadcom/tg3.c +0 -0
index d964f30..aee1b9a 100644

drivers/net/ethernet/broadcom/tg3.c static pci_ers_result_t tg3_io_error_detected(struct pci_dev *pdev, · line 17778

Quoted 7 lines
drivers/net/ethernet/broadcom/tg3.c +2 -1
@@ -17773,7 +17773,8 @@ static pci_ers_result_t tg3_io_error_detected(struct pci_dev *pdev,
 
 	rtnl_lock();
 
-	if (!netif_running(netdev))
+	/* We probably don't have netdev yet */
+	if (!netdev || !netif_running(netdev))
 		goto done;

This looks incomplete. 'done' does this..

done:

  if (state == pci_channel_io_perm_failure) {
          tg3_napi_enable(tp);
          dev_close(netdev);

If netdev is null, we'll deref it in dev_close.

Dave