Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp268721rwb; Fri, 18 Nov 2022 00:52:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf7lXDWJoyRtLrP9t+X5SMlwO1DJo1cIaDO3XT8jjSYTNgQNrG07H+MNhWNDg21o/IImkexF X-Received: by 2002:a17:906:d281:b0:782:7790:f132 with SMTP id ay1-20020a170906d28100b007827790f132mr5077387ejb.649.1668761561984; Fri, 18 Nov 2022 00:52:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668761561; cv=none; d=google.com; s=arc-20160816; b=dZnQi0XoxjTLmkuMdHSQTrXVnHNQpos4PdXNy+2pCUUp/my4GLqqOoZqLaz0srk8tI Y0BZkIsW4VDDnNgfVUuWZBWU1u0cC6fV39jJrl+D2IT1gO2h/LJEpWM2rn1Rapvy7k5u wJHT8Fu/hbykJjcG3RB3+aG/dQ2/XfLlRaVW2pc224LZcW3bFHl8h/FHMbpgGktroldh +fiR8F4ZNzw/qAj4Dv1cuJRisPNDsna7q1Pzu+3Pno81JC2lWyQFVklrpIEgSE/smTIM nlfWvzYC8Dy66/mX7ei4d/IVh70xwerYyGCxFiI7KGEuIi6nLtNBVWC779tgnljnOHpn CfTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:dkim-signature:from; bh=Y44J0Pt/nPO/pSFOAkMZfH8CxwueGH3Mwo6TRIGNryY=; b=QQbBrON/DGQCkctQYKgdSAp/DqJAWtY5En8JGeuVNUiCA0RvKDFw3xObAMgpBNAnCl kVwa91VN0tdlhPbVdc2nq38GaafA8ajcL+UDzBcanW/A/ubgxmQpRUffBVRj2ci9hkKQ gTAITslXFC/selByrWErNPEA/ngZ0K09C2YwohnOWxBVkkIyoEVeAa8+UQ1yOqUmHMKc lMveEb8ajSeac5GRYWwTBH9cJsB8MqMAuDB0bYaTJKc3TVNOjiDNoSkSaqRv7cBMoGbR WG52MeTOqssoHHO8w176SsPEe0U8yer9zBQqqOzLDm2/AD7LQ9AraSFXcIRfRUmGfqSQ sqSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@swemel.ru header.s=mail header.b=FD3cv8GS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=swemel.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z3-20020a05640235c300b00464718ca52bsi3079789edc.174.2022.11.18.00.52.18; Fri, 18 Nov 2022 00:52:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@swemel.ru header.s=mail header.b=FD3cv8GS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=swemel.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241307AbiKRIDY (ORCPT + 90 others); Fri, 18 Nov 2022 03:03:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241034AbiKRIDX (ORCPT ); Fri, 18 Nov 2022 03:03:23 -0500 Received: from mx.swemel.ru (mx.swemel.ru [95.143.211.150]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 460E8A1AC; Fri, 18 Nov 2022 00:03:21 -0800 (PST) From: Denis Arefev DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swemel.ru; s=mail; t=1668758598; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Y44J0Pt/nPO/pSFOAkMZfH8CxwueGH3Mwo6TRIGNryY=; b=FD3cv8GSsHNdpUradPl+tbsouvGeOVBrKzpKMCCfsnh+FaxwTusA77Ln0eEfgq1Ww9FrtZ D2a/MSg7Vet+FVU+usqJGBC+ngO6xDIW+9msuHNaPE3fLe4n3e+3CR1PicupTvyZuwb4ir HenHsjazlccNVJqh+UIdXio4iqEEyUI= To: Simon Horman Cc: Jakub Kicinski , "David S. Miller" , oss-drivers@netronome.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, trufanov@swemel.ru, vfh@swemel.ru Subject: [PATCH net v3] nfp: flower: Added pointer check and continue Date: Fri, 18 Nov 2022 11:03:17 +0300 Message-Id: <20221118080317.119749-1-arefev@swemel.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return value of a function 'kmalloc_array' is dereferenced at lag_conf.c:347 without checking for null, but it is usually checked for this function. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: bb9a8d031140 ("nfp: flower: monitor and offload LAG groups") Signed-off-by: Denis Arefev --- drivers/net/ethernet/netronome/nfp/flower/lag_conf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/lag_conf.c b/drivers/net/ethernet/netronome/nfp/flower/lag_conf.c index 63907aeb3884..1aaec4cb9f55 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/lag_conf.c +++ b/drivers/net/ethernet/netronome/nfp/flower/lag_conf.c @@ -276,7 +276,7 @@ static void nfp_fl_lag_do_work(struct work_struct *work) mutex_lock(&lag->lock); list_for_each_entry_safe(entry, storage, &lag->group_list, list) { - struct net_device *iter_netdev, **acti_netdevs; + struct net_device *iter_netdev, **acti_netdevs = NULL; struct nfp_flower_repr_priv *repr_priv; int active_count = 0, slaves = 0; struct nfp_repr *repr; @@ -308,6 +308,10 @@ static void nfp_fl_lag_do_work(struct work_struct *work) acti_netdevs = kmalloc_array(entry->slave_cnt, sizeof(*acti_netdevs), GFP_KERNEL); + if (!acti_netdevs) { + schedule_delayed_work(&lag->work, NFP_FL_LAG_DELAY); + continue; + } /* Include sanity check in the loop. It may be that a bond has * changed between processing the last notification and the -- 2.25.1