Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751328AbdHRLL6 (ORCPT ); Fri, 18 Aug 2017 07:11:58 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:57469 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750881AbdHRLL5 (ORCPT ); Fri, 18 Aug 2017 07:11:57 -0400 From: Colin King To: "David S . Miller" , Simon Horman , Daniel Borkmann , oss-drivers@netronome.com, netdev@vger.kernel.org Cc: Jakub Kicinski , linux-kernel@vger.kernel.org Subject: [PATCH] nfp: fix infinite loop on umapping cleanup Date: Fri, 18 Aug 2017 12:11:50 +0100 Message-Id: <20170818111150.13716-1-colin.king@canonical.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1109 Lines: 30 From: Colin Ian King 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 --- drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index 4a990033c4d5..732f1d315fba 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c @@ -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); -- 2.11.0