ethernet: Delete unnecessary checks before the macro call “dev_kfree_skb”
authorMarkus Elfring <elfring@users.sourceforge.net>
Thu, 22 Aug 2019 18:02:56 +0000 (20:02 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 22 Aug 2019 23:22:04 +0000 (16:22 -0700)
The dev_kfree_skb() function performs also input parameter validation.
Thus the test around the shown calls is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
20 files changed:
drivers/net/ethernet/amd/ni65.c
drivers/net/ethernet/broadcom/bcmsysport.c
drivers/net/ethernet/broadcom/genet/bcmgenet.c
drivers/net/ethernet/freescale/gianfar.c
drivers/net/ethernet/ibm/ehea/ehea_main.c
drivers/net/ethernet/intel/e1000/e1000_ethtool.c
drivers/net/ethernet/intel/e1000/e1000_main.c
drivers/net/ethernet/intel/e1000e/ethtool.c
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
drivers/net/ethernet/intel/igb/igb_main.c
drivers/net/ethernet/intel/igc/igc_main.c
drivers/net/ethernet/micrel/ks8842.c
drivers/net/ethernet/microchip/lan743x_ptp.c
drivers/net/ethernet/packetengines/yellowfin.c
drivers/net/ethernet/qualcomm/qca_spi.c
drivers/net/ethernet/qualcomm/qca_uart.c
drivers/net/ethernet/sgi/meth.c
drivers/net/ethernet/smsc/smc91x.c
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
drivers/net/ethernet/sun/sunvnet_common.c

index 87ff5d6d1b222a494359dcd95899c35ad34c0624..c6c2a54c1121da8c8eb0fc4707a015322cda3757 100644 (file)
@@ -697,16 +697,14 @@ static void ni65_free_buffer(struct priv *p)
        for(i=0;i<TMDNUM;i++) {
                kfree(p->tmdbounce[i]);
 #ifdef XMT_VIA_SKB
-               if(p->tmd_skb[i])
-                       dev_kfree_skb(p->tmd_skb[i]);
+               dev_kfree_skb(p->tmd_skb[i]);
 #endif
        }
 
        for(i=0;i<RMDNUM;i++)
        {
 #ifdef RCV_VIA_SKB
-               if(p->recv_skb[i])
-                       dev_kfree_skb(p->recv_skb[i]);
+               dev_kfree_skb(p->recv_skb[i]);
 #else
                kfree(p->recvbounce[i]);
 #endif
index cae66ba33c0b2e0cbb806555f53602630f0fd6d4..7df887e4024c8b75350d210e286abfb281e15587 100644 (file)
@@ -708,8 +708,7 @@ static int bcm_sysport_alloc_rx_bufs(struct bcm_sysport_priv *priv)
        for (i = 0; i < priv->num_rx_bds; i++) {
                cb = &priv->rx_cbs[i];
                skb = bcm_sysport_rx_refill(priv, cb);
-               if (skb)
-                       dev_kfree_skb(skb);
+               dev_kfree_skb(skb);
                if (!cb->skb)
                        return -ENOMEM;
        }
index 2108e59f592b8be305af8a1f2008bb960b8b0417..1586316eb6f1a8612d9aa7137263ac36c4290ed6 100644 (file)
@@ -2515,19 +2515,14 @@ static int bcmgenet_dma_teardown(struct bcmgenet_priv *priv)
 static void bcmgenet_fini_dma(struct bcmgenet_priv *priv)
 {
        struct netdev_queue *txq;
-       struct sk_buff *skb;
-       struct enet_cb *cb;
        int i;
 
        bcmgenet_fini_rx_napi(priv);
        bcmgenet_fini_tx_napi(priv);
 
-       for (i = 0; i < priv->num_tx_bds; i++) {
-               cb = priv->tx_cbs + i;
-               skb = bcmgenet_free_tx_cb(&priv->pdev->dev, cb);
-               if (skb)
-                       dev_kfree_skb(skb);
-       }
+       for (i = 0; i < priv->num_tx_bds; i++)
+               dev_kfree_skb(bcmgenet_free_tx_cb(&priv->pdev->dev,
+                                                 priv->tx_cbs + i));
 
        for (i = 0; i < priv->hw_params->tx_queues; i++) {
                txq = netdev_get_tx_queue(priv->dev, priv->tx_rings[i].queue);
index 7ea19e17333944846a5c1c6eeac3c84f67a611a9..412c0340fed92ce2db277aa15cf6814ff14c6527 100644 (file)
@@ -2005,8 +2005,7 @@ static void free_skb_rx_queue(struct gfar_priv_rx_q *rx_queue)
 
        struct rxbd8 *rxbdp = rx_queue->rx_bd_base;
 
-       if (rx_queue->skb)
-               dev_kfree_skb(rx_queue->skb);
+       dev_kfree_skb(rx_queue->skb);
 
        for (i = 0; i < rx_queue->rx_ring_size; i++) {
                struct  gfar_rx_buff *rxb = &rx_queue->rx_buff[i];
index cca71ba7a74a02b72d3c188368d6197278864243..13e30eba5349eadfdb41ae16407752ef084fccf8 100644 (file)
@@ -1577,20 +1577,16 @@ static int ehea_clean_portres(struct ehea_port *port, struct ehea_port_res *pr)
                ehea_destroy_eq(pr->eq);
 
                for (i = 0; i < pr->rq1_skba.len; i++)
-                       if (pr->rq1_skba.arr[i])
-                               dev_kfree_skb(pr->rq1_skba.arr[i]);
+                       dev_kfree_skb(pr->rq1_skba.arr[i]);
 
                for (i = 0; i < pr->rq2_skba.len; i++)
-                       if (pr->rq2_skba.arr[i])
-                               dev_kfree_skb(pr->rq2_skba.arr[i]);
+                       dev_kfree_skb(pr->rq2_skba.arr[i]);
 
                for (i = 0; i < pr->rq3_skba.len; i++)
-                       if (pr->rq3_skba.arr[i])
-                               dev_kfree_skb(pr->rq3_skba.arr[i]);
+                       dev_kfree_skb(pr->rq3_skba.arr[i]);
 
                for (i = 0; i < pr->sq_skba.len; i++)
-                       if (pr->sq_skba.arr[i])
-                               dev_kfree_skb(pr->sq_skba.arr[i]);
+                       dev_kfree_skb(pr->sq_skba.arr[i]);
 
                vfree(pr->rq1_skba.arr);
                vfree(pr->rq2_skba.arr);
index a41008523c983987d9252c60a77c014ddfca54a1..71d3d8854d8f124293399e5ac23aae6f328593fb 100644 (file)
@@ -937,8 +937,7 @@ static void e1000_free_desc_rings(struct e1000_adapter *adapter)
                                                 txdr->buffer_info[i].dma,
                                                 txdr->buffer_info[i].length,
                                                 DMA_TO_DEVICE);
-                       if (txdr->buffer_info[i].skb)
-                               dev_kfree_skb(txdr->buffer_info[i].skb);
+                       dev_kfree_skb(txdr->buffer_info[i].skb);
                }
        }
 
index 6b6ba1c3823521ffd5e211afddbbc96d65a27469..86493fea56e4cf5037dfb4de5ac1ee9ca40b5e21 100644 (file)
@@ -4175,8 +4175,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
                                /* an error means any chain goes out the window
                                 * too
                                 */
-                               if (rx_ring->rx_skb_top)
-                                       dev_kfree_skb(rx_ring->rx_skb_top);
+                               dev_kfree_skb(rx_ring->rx_skb_top);
                                rx_ring->rx_skb_top = NULL;
                                goto next_desc;
                        }
index 08342698386d6ebe320466018c6235e41da8d4cd..de8c5818a30500d53aa01a0eedafe46150595bf8 100644 (file)
@@ -1126,8 +1126,7 @@ static void e1000_free_desc_rings(struct e1000_adapter *adapter)
                                                 buffer_info->dma,
                                                 buffer_info->length,
                                                 DMA_TO_DEVICE);
-                       if (buffer_info->skb)
-                               dev_kfree_skb(buffer_info->skb);
+                       dev_kfree_skb(buffer_info->skb);
                }
        }
 
@@ -1139,8 +1138,7 @@ static void e1000_free_desc_rings(struct e1000_adapter *adapter)
                                dma_unmap_single(&pdev->dev,
                                                 buffer_info->dma,
                                                 2048, DMA_FROM_DEVICE);
-                       if (buffer_info->skb)
-                               dev_kfree_skb(buffer_info->skb);
+                       dev_kfree_skb(buffer_info->skb);
                }
        }
 
index d3e85480f46d616b4c289571f504450913f7ff17..09f7a246e13404ad66bf8cccf6fbcc643df3a936 100644 (file)
@@ -253,8 +253,7 @@ static void fm10k_clean_rx_ring(struct fm10k_ring *rx_ring)
        if (!rx_ring->rx_buffer)
                return;
 
-       if (rx_ring->skb)
-               dev_kfree_skb(rx_ring->skb);
+       dev_kfree_skb(rx_ring->skb);
        rx_ring->skb = NULL;
 
        /* Free all the Rx ring sk_buffs */
index b63e77528a91544e0e5041ef797b460db26a52b8..105b0624081a12bb6d375247856aacfa43bb6bd6 100644 (file)
@@ -4731,8 +4731,7 @@ static void igb_clean_rx_ring(struct igb_ring *rx_ring)
 {
        u16 i = rx_ring->next_to_clean;
 
-       if (rx_ring->skb)
-               dev_kfree_skb(rx_ring->skb);
+       dev_kfree_skb(rx_ring->skb);
        rx_ring->skb = NULL;
 
        /* Free all the Rx ring sk_buffs */
index e5114bebd30b40aa4c7570ea366a4ff1398f46c4..251552855c402f26b91fa98a7bae22acb48ecbf6 100644 (file)
@@ -352,8 +352,7 @@ static void igc_clean_rx_ring(struct igc_ring *rx_ring)
 {
        u16 i = rx_ring->next_to_clean;
 
-       if (rx_ring->skb)
-               dev_kfree_skb(rx_ring->skb);
+       dev_kfree_skb(rx_ring->skb);
        rx_ring->skb = NULL;
 
        /* Free all the Rx ring sk_buffs */
index ccd06702cc56bcd3930c4ad5a031133027eba80f..da329ca115cc7910b2603255cea70542aae0f3ea 100644 (file)
@@ -580,9 +580,7 @@ out:
                dma_unmap_single(adapter->dev, sg_dma_address(sg),
                        DMA_BUFFER_SIZE, DMA_FROM_DEVICE);
        sg_dma_address(sg) = 0;
-       if (ctl->skb)
-               dev_kfree_skb(ctl->skb);
-
+       dev_kfree_skb(ctl->skb);
        ctl->skb = NULL;
 
        printk(KERN_ERR DRV_NAME": Failed to start RX DMA: %d\n", err);
index b2109eca81fde4cb230474cb18a7ccd1310b8eb5..57b26c2acf877a3bc9fa974eaf24191e81ffac49 100644 (file)
@@ -963,8 +963,7 @@ void lan743x_ptp_close(struct lan743x_adapter *adapter)
                index++) {
                struct sk_buff *skb = ptp->tx_ts_skb_queue[index];
 
-               if (skb)
-                       dev_kfree_skb(skb);
+               dev_kfree_skb(skb);
                ptp->tx_ts_skb_queue[index] = NULL;
                ptp->tx_ts_seconds_queue[index] = 0;
                ptp->tx_ts_nseconds_queue[index] = 0;
index 6f8d6584f809146920772d79f4fd243c63b09957..5113ee6470903ec92bdf3229f376103a872792b0 100644 (file)
@@ -1258,8 +1258,7 @@ static int yellowfin_close(struct net_device *dev)
                yp->rx_skbuff[i] = NULL;
        }
        for (i = 0; i < TX_RING_SIZE; i++) {
-               if (yp->tx_skbuff[i])
-                       dev_kfree_skb(yp->tx_skbuff[i]);
+               dev_kfree_skb(yp->tx_skbuff[i]);
                yp->tx_skbuff[i] = NULL;
        }
 
index b28360bc2255e85bc5bdfb45b1313268f1f5e833..5ecf61df78bd95ac0d91a9feec9efc326242b26d 100644 (file)
@@ -837,8 +837,7 @@ qcaspi_netdev_uninit(struct net_device *dev)
 
        kfree(qca->rx_buffer);
        qca->buffer_size = 0;
-       if (qca->rx_skb)
-               dev_kfree_skb(qca->rx_skb);
+       dev_kfree_skb(qca->rx_skb);
 }
 
 static const struct net_device_ops qcaspi_netdev_ops = {
index 590616846cd168735ee701e1724f333441a1d2ad..0981068504fa711a4ca2d5c1b81205fd90860017 100644 (file)
@@ -285,8 +285,7 @@ static void qcauart_netdev_uninit(struct net_device *dev)
 {
        struct qcauart *qca = netdev_priv(dev);
 
-       if (qca->rx_skb)
-               dev_kfree_skb(qca->rx_skb);
+       dev_kfree_skb(qca->rx_skb);
 }
 
 static const struct net_device_ops qcauart_netdev_ops = {
index 00660dd820e26e9f6f17d67c3332eabc75ebcc1a..539bc5db989cd658c9c3f840c84c976763d72036 100644 (file)
@@ -247,8 +247,7 @@ static void meth_free_tx_ring(struct meth_private *priv)
 
        /* Remove any pending skb */
        for (i = 0; i < TX_RING_ENTRIES; i++) {
-               if (priv->tx_skbs[i])
-                       dev_kfree_skb(priv->tx_skbs[i]);
+               dev_kfree_skb(priv->tx_skbs[i]);
                priv->tx_skbs[i] = NULL;
        }
        dma_free_coherent(&priv->pdev->dev, TX_RING_BUFFER_SIZE, priv->tx_ring,
index 601e76ad99a0466ef3889f4ac713dc0c6c1a1180..3a6761131f4c2a67c2cf8edf6d7a6bc13b035b73 100644 (file)
@@ -378,8 +378,7 @@ static void smc_shutdown(struct net_device *dev)
        pending_skb = lp->pending_tx_skb;
        lp->pending_tx_skb = NULL;
        spin_unlock_irq(&lp->lock);
-       if (pending_skb)
-               dev_kfree_skb(pending_skb);
+       dev_kfree_skb(pending_skb);
 
        /* and tell the card to stay away from that nasty outside world */
        SMC_SELECT_BANK(lp, 0);
index bd1078433448c8cf5dc770c2c53563d5183d2d9f..06ccd216ae905293cfbca876106d09231a921fd9 100644 (file)
@@ -3519,8 +3519,7 @@ read_again:
                if (unlikely(error && (status & rx_not_ls)))
                        goto read_again;
                if (unlikely(error)) {
-                       if (skb)
-                               dev_kfree_skb(skb);
+                       dev_kfree_skb(skb);
                        continue;
                }
 
index 646e67236b65ca29687c69c500008e11ed9145d9..8b94d9ad9e2ba82ab3bf7683b8f348402f1b602c 100644 (file)
@@ -1532,8 +1532,7 @@ out_dropped:
        else if (port)
                del_timer(&port->clean_timer);
        rcu_read_unlock();
-       if (skb)
-               dev_kfree_skb(skb);
+       dev_kfree_skb(skb);
        vnet_free_skbs(freeskbs);
        dev->stats.tx_dropped++;
        return NETDEV_TX_OK;