nfp: fix infinite loop on umapping cleanup
authorColin Ian King <colin.king@canonical.com>
Fri, 18 Aug 2017 11:11:50 +0000 (12:11 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 18 Aug 2017 17:28:06 +0000 (10:28 -0700)
The while loop that performs the dma page unmapping never decrements
index counter f and hence loops forever. Fix this with a pre-decrement
on f.

Detected by CoverityScan, CID#1357309 ("Infinite loop")

Fixes: 4c3523623dc0 ("net: add driver for Netronome NFP4000/NFP6000 NIC VFs")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/netronome/nfp/nfp_net_common.c

index 4631ca8b8eb2780865bc2eefae51ce5c5a61f5cf..9f77ce038a4a339260e0118bb6a9f61e60547870 100644 (file)
@@ -908,8 +908,7 @@ static int nfp_net_tx(struct sk_buff *skb, struct net_device *netdev)
        return NETDEV_TX_OK;
 
 err_unmap:
-       --f;
-       while (f >= 0) {
+       while (--f >= 0) {
                frag = &skb_shinfo(skb)->frags[f];
                dma_unmap_page(dp->dev, tx_ring->txbufs[wr_idx].dma_addr,
                               skb_frag_size(frag), DMA_TO_DEVICE);