aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDon Fry <pcnet32@verizon.net>2009-07-31 04:45:29 -0400
committerDavid S. Miller <davem@davemloft.net>2009-08-02 15:23:06 -0400
commit63097b3ad85788a64c75091bff351ecc850761b2 (patch)
treeab194f0b2066db0c2b1267539dd40d182596ed7d
parentdf4e7f72f5156ef16a918da8a575ba90ec27ab77 (diff)
pcnet32: VLB support fixes
VLB support has been broken since at least 2004-2005 period as some changes introduced back then assumed that ->pci_dev is always valid, lets try to fix it: - remove duplicated SET_NETDEV_DEV() call - call SET_NETDEV_DEV() only for PCI devices - check for ->pci_dev validity in pcnet32_open() [ Alternatively we may consider removing VLB support but there would not be much gain in it since an extra driver code needed for VLB support is minimal and quite simple. ] This takes care of the following entry from Dan's list: drivers/net/pcnet32.c +1889 pcnet32_probe1(298) warning: variable derefenced before check 'pdev' Reported-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Acked-by: Don Fry <pcnet32@verizon.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/pcnet32.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index b61c97254b3f..16964ec73e67 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -1722,7 +1722,9 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1722 ret = -ENOMEM; 1722 ret = -ENOMEM;
1723 goto err_release_region; 1723 goto err_release_region;
1724 } 1724 }
1725 SET_NETDEV_DEV(dev, &pdev->dev); 1725
1726 if (pdev)
1727 SET_NETDEV_DEV(dev, &pdev->dev);
1726 1728
1727 if (pcnet32_debug & NETIF_MSG_PROBE) 1729 if (pcnet32_debug & NETIF_MSG_PROBE)
1728 printk(KERN_INFO PFX "%s at %#3lx,", chipname, ioaddr); 1730 printk(KERN_INFO PFX "%s at %#3lx,", chipname, ioaddr);
@@ -1821,7 +1823,6 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1821 1823
1822 spin_lock_init(&lp->lock); 1824 spin_lock_init(&lp->lock);
1823 1825
1824 SET_NETDEV_DEV(dev, &pdev->dev);
1825 lp->name = chipname; 1826 lp->name = chipname;
1826 lp->shared_irq = shared; 1827 lp->shared_irq = shared;
1827 lp->tx_ring_size = TX_RING_SIZE; /* default tx ring size */ 1828 lp->tx_ring_size = TX_RING_SIZE; /* default tx ring size */
@@ -2085,6 +2086,7 @@ static void pcnet32_free_ring(struct net_device *dev)
2085static int pcnet32_open(struct net_device *dev) 2086static int pcnet32_open(struct net_device *dev)
2086{ 2087{
2087 struct pcnet32_private *lp = netdev_priv(dev); 2088 struct pcnet32_private *lp = netdev_priv(dev);
2089 struct pci_dev *pdev = lp->pci_dev;
2088 unsigned long ioaddr = dev->base_addr; 2090 unsigned long ioaddr = dev->base_addr;
2089 u16 val; 2091 u16 val;
2090 int i; 2092 int i;
@@ -2145,9 +2147,9 @@ static int pcnet32_open(struct net_device *dev)
2145 lp->a.write_csr(ioaddr, 124, val); 2147 lp->a.write_csr(ioaddr, 124, val);
2146 2148
2147 /* Allied Telesyn AT 2700/2701 FX are 100Mbit only and do not negotiate */ 2149 /* Allied Telesyn AT 2700/2701 FX are 100Mbit only and do not negotiate */
2148 if (lp->pci_dev->subsystem_vendor == PCI_VENDOR_ID_AT && 2150 if (pdev && pdev->subsystem_vendor == PCI_VENDOR_ID_AT &&
2149 (lp->pci_dev->subsystem_device == PCI_SUBDEVICE_ID_AT_2700FX || 2151 (pdev->subsystem_device == PCI_SUBDEVICE_ID_AT_2700FX ||
2150 lp->pci_dev->subsystem_device == PCI_SUBDEVICE_ID_AT_2701FX)) { 2152 pdev->subsystem_device == PCI_SUBDEVICE_ID_AT_2701FX)) {
2151 if (lp->options & PCNET32_PORT_ASEL) { 2153 if (lp->options & PCNET32_PORT_ASEL) {
2152 lp->options = PCNET32_PORT_FD | PCNET32_PORT_100; 2154 lp->options = PCNET32_PORT_FD | PCNET32_PORT_100;
2153 if (netif_msg_link(lp)) 2155 if (netif_msg_link(lp))