From: Colin Ian King Date: Mon, 11 Jul 2016 15:54:20 +0000 (+0100) Subject: nfp: check idx is -ENOSPC before using it is an index X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f50cef6f77d08fced02eba7ac7c1cab4972c3786;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git nfp: check idx is -ENOSPC before using it is an index 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 Acked-by: Jakub Kicinski Signed-off-by: David S. Miller --- diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index 1e74b911accb..88678c172b19 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])