drivers/net: Remove pointless checks for NULL prior to calling kfree()
Jesper Juhl [Fri, 28 Oct 2005 20:53:13 +0000 (16:53 -0400)]
32 files changed:
drivers/net/acenic.c
drivers/net/au1000_eth.c
drivers/net/b44.c
drivers/net/bmac.c
drivers/net/bnx2.c
drivers/net/e1000/e1000_ethtool.c
drivers/net/hamradio/mkiss.c
drivers/net/ibmveth.c
drivers/net/irda/donauboe.c
drivers/net/irda/irda-usb.c
drivers/net/irda/irport.c
drivers/net/irda/sir_dev.c
drivers/net/irda/vlsi_ir.c
drivers/net/mace.c
drivers/net/ni65.c
drivers/net/rrunner.c
drivers/net/s2io.c
drivers/net/saa9730.c
drivers/net/tg3.c
drivers/net/tulip/de2104x.c
drivers/net/tulip/tulip_core.c
drivers/net/via-velocity.c
drivers/net/wireless/airo.c
drivers/net/wireless/airo_cs.c
drivers/net/wireless/atmel.c
drivers/net/wireless/atmel_cs.c
drivers/net/wireless/hostap/hostap_ioctl.c
drivers/net/wireless/prism54/islpci_dev.c
drivers/net/wireless/prism54/oid_mgt.c
drivers/net/wireless/strip.c
include/net/ax25.h
include/net/netrom.h

index dbecc6b..b8953de 100644 (file)
@@ -871,10 +871,8 @@ static void ace_init_cleanup(struct net_device *dev)
        if (ap->info)
                pci_free_consistent(ap->pdev, sizeof(struct ace_info),
                                    ap->info, ap->info_dma);
-       if (ap->skb)
-               kfree(ap->skb);
-       if (ap->trace_buf)
-               kfree(ap->trace_buf);
+       kfree(ap->skb);
+       kfree(ap->trace_buf);
 
        if (dev->irq)
                free_irq(dev->irq, dev);
index 7850691..332e995 100644 (file)
@@ -1606,8 +1606,7 @@ err_out:
        /* here we should have a valid dev plus aup-> register addresses
         * so we can reset the mac properly.*/
        reset_mac(dev);
-       if (aup->mii)
-               kfree(aup->mii);
+       kfree(aup->mii);
        for (i = 0; i < NUM_RX_DMA; i++) {
                if (aup->rx_db_inuse[i])
                        ReleaseDB(aup, aup->rx_db_inuse[i]);
@@ -1806,8 +1805,7 @@ static void __exit au1000_cleanup_module(void)
                if (dev) {
                        aup = (struct au1000_private *) dev->priv;
                        unregister_netdev(dev);
-                       if (aup->mii)
-                               kfree(aup->mii);
+                       kfree(aup->mii);
                        for (j = 0; j < NUM_RX_DMA; j++) {
                                if (aup->rx_db_inuse[j])
                                        ReleaseDB(aup, aup->rx_db_inuse[j]);
index ab84507..5485e3b 100644 (file)
@@ -1131,14 +1131,10 @@ static void b44_init_rings(struct b44 *bp)
  */
 static void b44_free_consistent(struct b44 *bp)
 {
-       if (bp->rx_buffers) {
-               kfree(bp->rx_buffers);
-               bp->rx_buffers = NULL;
-       }
-       if (bp->tx_buffers) {
-               kfree(bp->tx_buffers);
-               bp->tx_buffers = NULL;
-       }
+       kfree(bp->rx_buffers);
+       bp->rx_buffers = NULL;
+       kfree(bp->tx_buffers);
+       bp->tx_buffers = NULL;
        if (bp->rx_ring) {
                if (bp->flags & B44_FLAG_RX_RING_HACK) {
                        dma_unmap_single(&bp->pdev->dev, bp->rx_ring_dma,
index 60dba4a..73f2fcf 100644 (file)
@@ -1689,10 +1689,8 @@ static void __exit bmac_exit(void)
 {
        macio_unregister_driver(&bmac_driver);
 
-       if (bmac_emergency_rxbuf != NULL) {
-               kfree(bmac_emergency_rxbuf);
-               bmac_emergency_rxbuf = NULL;
-       }
+       kfree(bmac_emergency_rxbuf);
+       bmac_emergency_rxbuf = NULL;
 }
 
 MODULE_AUTHOR("Randy Gobbel/Paul Mackerras");
index 3a2ace0..11d2523 100644 (file)
@@ -314,20 +314,16 @@ bnx2_free_mem(struct bnx2 *bp)
                                    bp->tx_desc_ring, bp->tx_desc_mapping);
                bp->tx_desc_ring = NULL;
        }
-       if (bp->tx_buf_ring) {
-               kfree(bp->tx_buf_ring);
-               bp->tx_buf_ring = NULL;
-       }
+       kfree(bp->tx_buf_ring);
+       bp->tx_buf_ring = NULL;
        if (bp->rx_desc_ring) {
                pci_free_consistent(bp->pdev,
                                    sizeof(struct rx_bd) * RX_DESC_CNT,
                                    bp->rx_desc_ring, bp->rx_desc_mapping);
                bp->rx_desc_ring = NULL;
        }
-       if (bp->rx_buf_ring) {
-               kfree(bp->rx_buf_ring);
-               bp->rx_buf_ring = NULL;
-       }
+       kfree(bp->rx_buf_ring);
+       bp->rx_buf_ring = NULL;
 }
 
 static int
index 6b9acc7..9c7feae 100644 (file)
@@ -965,11 +965,8 @@ e1000_free_desc_rings(struct e1000_adapter *adapter)
        if(rxdr->desc)
                pci_free_consistent(pdev, rxdr->size, rxdr->desc, rxdr->dma);
 
-       if(txdr->buffer_info)
-               kfree(txdr->buffer_info);
-       if(rxdr->buffer_info)
-               kfree(rxdr->buffer_info);
-
+       kfree(txdr->buffer_info);
+       kfree(rxdr->buffer_info);
        return;
 }
 
index 85d6dc0..3e9accf 100644 (file)
@@ -390,10 +390,8 @@ static void ax_changedmtu(struct mkiss *ax)
                       "MTU change cancelled.\n",
                       ax->dev->name);
                dev->mtu = ax->mtu;
-               if (xbuff != NULL)
-                       kfree(xbuff);
-               if (rbuff != NULL)
-                       kfree(rbuff);
+               kfree(xbuff);
+               kfree(rbuff);
                return;
        }
 
index f581952..36da54a 100644 (file)
@@ -276,10 +276,8 @@ static void ibmveth_free_buffer_pool(struct ibmveth_adapter *adapter, struct ibm
 {
        int i;
 
-       if(pool->free_map) {
-               kfree(pool->free_map);
-               pool->free_map  = NULL;
-       }
+       kfree(pool->free_map);
+       pool->free_map = NULL;
 
        if(pool->skbuff && pool->dma_addr) {
                for(i = 0; i < pool->size; ++i) {
index 0a08c53..0282771 100644 (file)
@@ -1695,11 +1695,9 @@ toshoboe_open (struct pci_dev *pci_dev, const struct pci_device_id *pdid)
 
 freebufs:
   for (i = 0; i < TX_SLOTS; ++i)
-    if (self->tx_bufs[i])
-      kfree (self->tx_bufs[i]);
+    kfree (self->tx_bufs[i]);
   for (i = 0; i < RX_SLOTS; ++i)
-    if (self->rx_bufs[i])
-      kfree (self->rx_bufs[i]);
+    kfree (self->rx_bufs[i]);
   kfree(self->ringbuf);
 
 freeregion:
index 6c766fd..c22c051 100644 (file)
@@ -1168,10 +1168,8 @@ static inline void irda_usb_close(struct irda_usb_cb *self)
        unregister_netdev(self->netdev);
 
        /* Remove the speed buffer */
-       if (self->speed_buff != NULL) {
-               kfree(self->speed_buff);
-               self->speed_buff = NULL;
-       }
+       kfree(self->speed_buff);
+       self->speed_buff = NULL;
 }
 
 /********************** USB CONFIG SUBROUTINES **********************/
index 5971315..3d016a4 100644 (file)
@@ -235,8 +235,7 @@ static int irport_close(struct irport_cb *self)
                   __FUNCTION__, self->io.sir_base);
        release_region(self->io.sir_base, self->io.sir_ext);
 
-       if (self->tx_buff.head)
-               kfree(self->tx_buff.head);
+       kfree(self->tx_buff.head);
        
        if (self->rx_buff.skb)
                kfree_skb(self->rx_buff.skb);
index efc5a88..df22b8b 100644 (file)
@@ -490,8 +490,7 @@ static void sirdev_free_buffers(struct sir_dev *dev)
 {
        if (dev->rx_buff.skb)
                kfree_skb(dev->rx_buff.skb);
-       if (dev->tx_buff.head)
-               kfree(dev->tx_buff.head);
+       kfree(dev->tx_buff.head);
        dev->rx_buff.head = dev->tx_buff.head = NULL;
        dev->rx_buff.skb = NULL;
 }
index 651c5a6..a9f49f0 100644 (file)
@@ -473,8 +473,7 @@ static int vlsi_free_ring(struct vlsi_ring *r)
                rd_set_addr_status(rd, 0, 0);
                if (busaddr)
                        pci_unmap_single(r->pdev, busaddr, r->len, r->dir);
-               if (rd->buf)
-                       kfree(rd->buf);
+               kfree(rd->buf);
        }
        kfree(r);
        return 0;
index 81d0a26..09b1e7b 100644 (file)
@@ -1035,10 +1035,8 @@ static void __exit mace_cleanup(void)
 {
        macio_unregister_driver(&mace_driver);
 
-       if (dummy_buf) {
-               kfree(dummy_buf);
-               dummy_buf = NULL;
-       }
+       kfree(dummy_buf);
+       dummy_buf = NULL;
 }
 
 MODULE_AUTHOR("Paul Mackerras");
index 925d1df..bb42ff2 100644 (file)
@@ -696,8 +696,7 @@ static void ni65_free_buffer(struct priv *p)
                return;
 
        for(i=0;i<TMDNUM;i++) {
-               if(p->tmdbounce[i])
-                       kfree(p->tmdbounce[i]);
+               kfree(p->tmdbounce[i]);
 #ifdef XMT_VIA_SKB
                if(p->tmd_skb[i])
                        dev_kfree_skb(p->tmd_skb[i]);
@@ -710,12 +709,10 @@ static void ni65_free_buffer(struct priv *p)
                if(p->recv_skb[i])
                        dev_kfree_skb(p->recv_skb[i]);
 #else
-               if(p->recvbounce[i])
-                       kfree(p->recvbounce[i]);
+               kfree(p->recvbounce[i]);
 #endif
        }
-       if(p->self)
-               kfree(p->self);
+       kfree(p->self);
 }
 
 
index ec1a18d..19c2df9 100644 (file)
@@ -1710,10 +1710,8 @@ static int rr_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
                        error = -EFAULT;
                }
        wf_out:
-               if (oldimage)
-                       kfree(oldimage);
-               if (image)
-                       kfree(image);
+               kfree(oldimage);
+               kfree(image);
                return error;
                
        case SIOCRRID:
index d303d16..5ea8977 100644 (file)
@@ -705,8 +705,7 @@ static void free_shared_mem(struct s2io_nic *nic)
                        }
                        kfree(mac_control->rings[i].ba[j]);
                }
-               if (mac_control->rings[i].ba)
-                       kfree(mac_control->rings[i].ba);
+               kfree(mac_control->rings[i].ba);
        }
 #endif
 
index fd01670..110e777 100644 (file)
@@ -997,10 +997,7 @@ static void __devexit saa9730_remove_one(struct pci_dev *pdev)
 
         if (dev) {
                 unregister_netdev(dev);
-
-               if (dev->priv)
-                       kfree(dev->priv);
-
+               kfree(dev->priv);
                 free_netdev(dev);
                 pci_release_regions(pdev);
                 pci_disable_device(pdev);
@@ -1096,8 +1093,7 @@ static int lan_saa9730_init(struct net_device *dev, int ioaddr, int irq)
        return 0;
 
  out:
-       if (dev->priv)
-               kfree(dev->priv);
+       kfree(dev->priv);
        return ret;
 }
 
index 551c944..b547233 100644 (file)
@@ -3918,10 +3918,8 @@ static void tg3_init_rings(struct tg3 *tp)
  */
 static void tg3_free_consistent(struct tg3 *tp)
 {
-       if (tp->rx_std_buffers) {
-               kfree(tp->rx_std_buffers);
-               tp->rx_std_buffers = NULL;
-       }
+       kfree(tp->rx_std_buffers);
+       tp->rx_std_buffers = NULL;
        if (tp->rx_std) {
                pci_free_consistent(tp->pdev, TG3_RX_RING_BYTES,
                                    tp->rx_std, tp->rx_std_mapping);
index 6b8eee8..d7fb3ff 100644 (file)
@@ -2076,8 +2076,7 @@ static int __init de_init_one (struct pci_dev *pdev,
        return 0;
 
 err_out_iomap:
-       if (de->ee_data)
-               kfree(de->ee_data);
+       kfree(de->ee_data);
        iounmap(regs);
 err_out_res:
        pci_release_regions(pdev);
@@ -2096,8 +2095,7 @@ static void __exit de_remove_one (struct pci_dev *pdev)
        if (!dev)
                BUG();
        unregister_netdev(dev);
-       if (de->ee_data)
-               kfree(de->ee_data);
+       kfree(de->ee_data);
        iounmap(de->regs);
        pci_release_regions(pdev);
        pci_disable_device(pdev);
index 6266a9a..125ed00 100644 (file)
@@ -1727,8 +1727,7 @@ err_out_free_ring:
                             tp->rx_ring, tp->rx_ring_dma);
 
 err_out_mtable:
-       if (tp->mtable)
-               kfree (tp->mtable);
+       kfree (tp->mtable);
        pci_iounmap(pdev, ioaddr);
 
 err_out_free_res:
@@ -1806,8 +1805,7 @@ static void __devexit tulip_remove_one (struct pci_dev *pdev)
                             sizeof (struct tulip_rx_desc) * RX_RING_SIZE +
                             sizeof (struct tulip_tx_desc) * TX_RING_SIZE,
                             tp->rx_ring, tp->rx_ring_dma);
-       if (tp->mtable)
-               kfree (tp->mtable);
+       kfree (tp->mtable);
        pci_iounmap(pdev, tp->base_addr);
        free_netdev (dev);
        pci_release_regions (pdev);
index abc5cee..a368d08 100644 (file)
@@ -1212,10 +1212,8 @@ static void velocity_free_td_ring(struct velocity_info *vptr)
                        velocity_free_td_ring_entry(vptr, j, i);
 
                }
-               if (vptr->td_infos[j]) {
-                       kfree(vptr->td_infos[j]);
-                       vptr->td_infos[j] = NULL;
-               }
+               kfree(vptr->td_infos[j]);
+               vptr->td_infos[j] = NULL;
        }
 }
 
index cb429e7..4c11699 100644 (file)
@@ -2381,14 +2381,10 @@ void stop_airo_card( struct net_device *dev, int freeres )
                        dev_kfree_skb(skb);
        }
 
-       if (ai->flash)
-               kfree(ai->flash);
-       if (ai->rssi)
-               kfree(ai->rssi);
-       if (ai->APList)
-               kfree(ai->APList);
-       if (ai->SSID)
-               kfree(ai->SSID);
+       kfree(ai->flash);
+       kfree(ai->rssi);
+       kfree(ai->APList);
+       kfree(ai->SSID);
        if (freeres) {
                /* PCMCIA frees this stuff, so only for PCI and ISA */
                release_region( dev->base_addr, 64 );
@@ -3626,10 +3622,8 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
        int rc;
 
        memset( &mySsid, 0, sizeof( mySsid ) );
-       if (ai->flash) {
-               kfree (ai->flash);
-               ai->flash = NULL;
-       }
+       kfree (ai->flash);
+       ai->flash = NULL;
 
        /* The NOP is the first step in getting the card going */
        cmd.cmd = NOP;
@@ -3666,14 +3660,10 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
                tdsRssiRid rssi_rid;
                CapabilityRid cap_rid;
 
-               if (ai->APList) {
-                       kfree(ai->APList);
-                       ai->APList = NULL;
-               }
-               if (ai->SSID) {
-                       kfree(ai->SSID);
-                       ai->SSID = NULL;
-               }
+               kfree(ai->APList);
+               ai->APList = NULL;
+               kfree(ai->SSID);
+               ai->SSID = NULL;
                // general configuration (read/modify/write)
                status = readConfigRid(ai, lock);
                if ( status != SUCCESS ) return ERROR;
@@ -3687,10 +3677,8 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
                                memcpy(ai->rssi, (u8*)&rssi_rid + 2, 512); /* Skip RID length member */
                }
                else {
-                       if (ai->rssi) {
-                               kfree(ai->rssi);
-                               ai->rssi = NULL;
-                       }
+                       kfree(ai->rssi);
+                       ai->rssi = NULL;
                        if (cap_rid.softCap & 8)
                                ai->config.rmode |= RXMODE_NORMALIZED_RSSI;
                        else
@@ -5369,11 +5357,13 @@ static int proc_BSSList_open( struct inode *inode, struct file *file ) {
 
 static int proc_close( struct inode *inode, struct file *file )
 {
-       struct proc_data *data = (struct proc_data *)file->private_data;
-       if ( data->on_close != NULL ) data->on_close( inode, file );
-       if ( data->rbuffer ) kfree( data->rbuffer );
-       if ( data->wbuffer ) kfree( data->wbuffer );
-       kfree( data );
+       struct proc_data *data = file->private_data;
+
+       if (data->on_close != NULL)
+               data->on_close(inode, file);
+       kfree(data->rbuffer);
+       kfree(data->wbuffer);
+       kfree(data);
        return 0;
 }
 
index bf25584..784de91 100644 (file)
@@ -258,9 +258,7 @@ static void airo_detach(dev_link_t *link)
        
        /* Unlink device structure, free pieces */
        *linkp = link->next;
-       if (link->priv) {
-               kfree(link->priv);
-       }
+       kfree(link->priv);
        kfree(link);
        
 } /* airo_detach */
index d570110..1fbe027 100644 (file)
@@ -1653,8 +1653,7 @@ void stop_atmel_card(struct net_device *dev, int freeres)
        unregister_netdev(dev);
        remove_proc_entry("driver/atmel", NULL);
        free_irq(dev->irq, dev);
-       if (priv->firmware)
-               kfree(priv->firmware);
+       kfree(priv->firmware);
        if (freeres) {
                /* PCMCIA frees this stuff, so only for PCI */
                release_region(dev->base_addr, 64);
@@ -2450,8 +2449,7 @@ static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
                        break;
                }
 
-               if (priv->firmware)
-                       kfree(priv->firmware);
+               kfree(priv->firmware);
                
                priv->firmware = new_firmware;
                priv->firmware_length = com.len;
index ff031a3..195cb36 100644 (file)
@@ -259,8 +259,7 @@ static void atmel_detach(dev_link_t *link)
 
        /* Unlink device structure, free pieces */
        *linkp = link->next;
-       if (link->priv)
-               kfree(link->priv);
+       kfree(link->priv);
        kfree(link);
 }
 
index 53f5246..2617d70 100644 (file)
@@ -552,7 +552,6 @@ static int prism2_ioctl_giwaplist(struct net_device *dev,
 
        kfree(addr);
        kfree(qual);
-
        return 0;
 }
 
@@ -3081,9 +3080,7 @@ static int prism2_ioctl_priv_download(local_info_t *local, struct iw_point *p)
        ret = local->func->download(local, param);
 
  out:
-       if (param != NULL)
-               kfree(param);
-
+       kfree(param);
        return ret;
 }
 #endif /* PRISM2_DOWNLOAD_SUPPORT */
@@ -3890,9 +3887,7 @@ static int prism2_ioctl_priv_hostapd(local_info_t *local, struct iw_point *p)
        }
 
  out:
-       if (param != NULL)
-               kfree(param);
-
+       kfree(param);
        return ret;
 }
 
index 6c9584a..78bdb35 100644 (file)
@@ -754,8 +754,7 @@ islpci_free_memory(islpci_private *priv)
                        pci_unmap_single(priv->pdev, buf->pci_addr,
                                         buf->size, PCI_DMA_FROMDEVICE);
                buf->pci_addr = 0;
-               if (buf->mem)
-                       kfree(buf->mem);
+               kfree(buf->mem);
                buf->size = 0;
                buf->mem = NULL;
         }
index 12123e2..eea2f04 100644 (file)
@@ -268,11 +268,10 @@ mgt_clean(islpci_private *priv)
 
        if (!priv->mib)
                return;
-       for (i = 0; i < OID_NUM_LAST; i++)
-               if (priv->mib[i]) {
-                       kfree(priv->mib[i]);
-                       priv->mib[i] = NULL;
-               }
+       for (i = 0; i < OID_NUM_LAST; i++) {
+               kfree(priv->mib[i]);
+               priv->mib[i] = NULL;
+       }
        kfree(priv->mib);
        priv->mib = NULL;
 }
index 7bc7fc8..d25264b 100644 (file)
@@ -860,12 +860,9 @@ static int allocate_buffers(struct strip *strip_info, int mtu)
                strip_info->mtu = dev->mtu = mtu;
                return (1);
        }
-       if (r)
-               kfree(r);
-       if (s)
-               kfree(s);
-       if (t)
-               kfree(t);
+       kfree(r);
+       kfree(s);
+       kfree(t);
        return (0);
 }
 
@@ -922,13 +919,9 @@ static int strip_change_mtu(struct net_device *dev, int new_mtu)
        printk(KERN_NOTICE "%s: strip MTU changed fom %d to %d.\n",
               strip_info->dev->name, old_mtu, strip_info->mtu);
 
-       if (orbuff)
-               kfree(orbuff);
-       if (osbuff)
-               kfree(osbuff);
-       if (otbuff)
-               kfree(otbuff);
-
+       kfree(orbuff);
+       kfree(osbuff);
+       kfree(otbuff);
        return 0;
 }
 
@@ -2498,18 +2491,13 @@ static int strip_close_low(struct net_device *dev)
        /*
         * Free all STRIP frame buffers.
         */
-       if (strip_info->rx_buff) {
-               kfree(strip_info->rx_buff);
-               strip_info->rx_buff = NULL;
-       }
-       if (strip_info->sx_buff) {
-               kfree(strip_info->sx_buff);
-               strip_info->sx_buff = NULL;
-       }
-       if (strip_info->tx_buff) {
-               kfree(strip_info->tx_buff);
-               strip_info->tx_buff = NULL;
-       }
+       kfree(strip_info->rx_buff);
+       strip_info->rx_buff = NULL;
+       kfree(strip_info->sx_buff);
+       strip_info->sx_buff = NULL;
+       kfree(strip_info->tx_buff);
+       strip_info->tx_buff = NULL;
+
        del_timer(&strip_info->idle_timer);
        return 0;
 }
index 30bb4a8..2250a18 100644 (file)
@@ -237,8 +237,7 @@ typedef struct ax25_cb {
 static __inline__ void ax25_cb_put(ax25_cb *ax25)
 {
        if (atomic_dec_and_test(&ax25->refcount)) {
-               if (ax25->digipeat)
-                       kfree(ax25->digipeat);
+               kfree(ax25->digipeat);
                kfree(ax25);
        }
 }
index a6bf6e0..a5ee53b 100644 (file)
@@ -136,8 +136,7 @@ static __inline__ void nr_node_put(struct nr_node *nr_node)
 static __inline__ void nr_neigh_put(struct nr_neigh *nr_neigh)
 {
        if (atomic_dec_and_test(&nr_neigh->refcount)) {
-               if (nr_neigh->digipeat != NULL)
-                       kfree(nr_neigh->digipeat);
+               kfree(nr_neigh->digipeat);
                kfree(nr_neigh);
        }
 }