nfp: check idx is -ENOSPC before using it is an index
authorColin Ian King <colin.king@canonical.com>
Mon, 11 Jul 2016 15:54:20 +0000 (16:54 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 11 Jul 2016 20:52:00 +0000 (13:52 -0700)
idx can be returned as -ENOSPC, so we should check for this first
before using it as an index into nn->vxlan_usecnt[] to avoid an
out of bounds array offset read.

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 1e74b911accb6aa54d06bbf8ff2230773f581b79..88678c172b19f14e7ae00574cab4da76f1edcced 100644 (file)
@@ -2578,7 +2578,7 @@ static void nfp_net_del_vxlan_port(struct net_device *netdev,
                return;
 
        idx = nfp_net_find_vxlan_idx(nn, ti->port);
-       if (!nn->vxlan_usecnt[idx] || idx == -ENOSPC)
+       if (idx == -ENOSPC || !nn->vxlan_usecnt[idx])
                return;
 
        if (!--nn->vxlan_usecnt[idx])