Commit 549a68c3 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by Jeff Garzik

sky2: fix oops on shutdown

If the device is fails during module startup for some reason like
unsupported chip version then the driver would crash dereferencing a
null pointer, on shutdown or suspend/resume.
Signed-off-by: default avatarStephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent 4093785d
...@@ -3732,6 +3732,7 @@ err_out_free_regions: ...@@ -3732,6 +3732,7 @@ err_out_free_regions:
err_out_disable: err_out_disable:
pci_disable_device(pdev); pci_disable_device(pdev);
err_out: err_out:
pci_set_drvdata(pdev, NULL);
return err; return err;
} }
...@@ -3784,6 +3785,9 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -3784,6 +3785,9 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state)
struct sky2_hw *hw = pci_get_drvdata(pdev); struct sky2_hw *hw = pci_get_drvdata(pdev);
int i, wol = 0; int i, wol = 0;
if (!hw)
return 0;
del_timer_sync(&hw->idle_timer); del_timer_sync(&hw->idle_timer);
netif_poll_disable(hw->dev[0]); netif_poll_disable(hw->dev[0]);
...@@ -3815,6 +3819,9 @@ static int sky2_resume(struct pci_dev *pdev) ...@@ -3815,6 +3819,9 @@ static int sky2_resume(struct pci_dev *pdev)
struct sky2_hw *hw = pci_get_drvdata(pdev); struct sky2_hw *hw = pci_get_drvdata(pdev);
int i, err; int i, err;
if (!hw)
return 0;
err = pci_set_power_state(pdev, PCI_D0); err = pci_set_power_state(pdev, PCI_D0);
if (err) if (err)
goto out; goto out;
...@@ -3861,6 +3868,9 @@ static void sky2_shutdown(struct pci_dev *pdev) ...@@ -3861,6 +3868,9 @@ static void sky2_shutdown(struct pci_dev *pdev)
struct sky2_hw *hw = pci_get_drvdata(pdev); struct sky2_hw *hw = pci_get_drvdata(pdev);
int i, wol = 0; int i, wol = 0;
if (!hw)
return;
del_timer_sync(&hw->idle_timer); del_timer_sync(&hw->idle_timer);
netif_poll_disable(hw->dev[0]); netif_poll_disable(hw->dev[0]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment