From patchwork Mon Jul 11 15:54:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 9223803 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1B68060871 for ; Mon, 11 Jul 2016 15:55:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E54827569 for ; Mon, 11 Jul 2016 15:55:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02A4D27DCD; Mon, 11 Jul 2016 15:55:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF11D27569 for ; Mon, 11 Jul 2016 15:55:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759426AbcGKPzA (ORCPT ); Mon, 11 Jul 2016 11:55:00 -0400 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 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1bMdXq-0006VQ-64; Mon, 11 Jul 2016 15:54:54 +0000 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> X-Mailer: git-send-email 2.8.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Jakub Kicinski --- 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])