Return-path: Received: from youngberry.canonical.com ([91.189.89.112]:38600 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755085AbcGKPy7 (ORCPT ); Mon, 11 Jul 2016 11:54:59 -0400 From: Colin King To: Jakub Kicinski , Lauro Ramos Venancio , Aloisio Almeida Jr , Samuel Ortiz , "David S . Miller" , Rolf Neugebauer , Christophe Ricard , Robert Dolca , oss-drivers@netronome.com, netdev@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH][V2] nfp: check idx is -ENOSPC before using it is an index Date: Mon, 11 Jul 2016 16:54:20 +0100 Message-Id: <1468252460-15117-1-git-send-email-colin.king@canonical.com> (sfid-20160711_175506_841012_C9293A60) Sender: linux-wireless-owner@vger.kernel.org List-ID: From: Colin Ian King 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 --- drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index 1e74b91..88678c1 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c @@ -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]) -- 2.8.1