Message ID | 20221116081336.83373-1-arefev@swemel.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp22192wru; Wed, 16 Nov 2022 00:25:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf5zkqnEpuFI25JFxS0/+qCcYJqLGv3t2W5DI8hFi1cGBrZiTf62fAFbGK9+3wBTj2xIAZPF X-Received: by 2002:a17:90b:2811:b0:213:971d:51b4 with SMTP id qb17-20020a17090b281100b00213971d51b4mr2442164pjb.180.1668587120471; Wed, 16 Nov 2022 00:25:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668587120; cv=none; d=google.com; s=arc-20160816; b=kEBn/RxMnYR9pYexPqIgmb3naU04fpEOGa/qS34gQoTtXZu4cgbrLatiQgyxik4MvW wqY6DUfICwhU7kGY48W147TFd3jA71Www1CPbhIQpTxLjleSVRkO/xcq+k+17vU8GRGu bBuqEjJ/SFF+03q/jLXNCyDGmM7F+b/AsOxqlLaNaL2pzp4/MRCQMP8G9yGcWcQFE/Ny bWGclM+lZgcsI/2jbN2NLpE7nx7mXlvSL0bW5K7aosd3Bv8u6hYtguiRFcAiMwqtwE15 mnPehH9Ttvgjn/HqWSuBvhy9xBjPKsSozfzZvNmPP39fUFuEajXRqGJ4kVZcFYbLu2Le arkA== 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=hjmjzVkqQPjx/npqqU/y02BPLs+FOpb+o0cfroaLLuc=; b=OA89e3fRLveWJUDeqWdjatTAnu2dJNCO3bZ4nNX+IYHuZwLVBH3WcDPNAX3RVSWkCe qXswEz94R4mQvHo98N9LnflKIdJ8bzR3nV8sW1kXHheEe3p8q5x7oND3mD4iyOzN8kNe pvRNKXVfB01RxqmaSUQU00WIRyHNjdDQTffyIdFh/gVRTm2PFl6ZGmzT048xuijN/jjq 1fTHsfdFrPZ4Wr+8ORB7jAEZZOwa5J9lBDyxaAaGyRjAexXFIAV19Md5A1zQBRLCd6TE etFW0wTw8FmrceIenJBdAswKn926JRwRNRwrKWs6x9qAoBxM1X7C03EYjbGpkhl8LuVS 9c+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@swemel.ru header.s=mail header.b=PJB6PZXg; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l19-20020a17090b079300b0020ab20c54fesi1270834pjz.114.2022.11.16.00.25.07; Wed, 16 Nov 2022 00:25:20 -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=PJB6PZXg; 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 S238680AbiKPIOk (ORCPT <rfc822;maxim.cournoyer@gmail.com> + 99 others); Wed, 16 Nov 2022 03:14:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232483AbiKPIOX (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 16 Nov 2022 03:14:23 -0500 Received: from mx.swemel.ru (mx.swemel.ru [95.143.211.150]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7037EB878; Wed, 16 Nov 2022 00:13:39 -0800 (PST) From: Denis Arefev <arefev@swemel.ru> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swemel.ru; s=mail; t=1668586416; 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=hjmjzVkqQPjx/npqqU/y02BPLs+FOpb+o0cfroaLLuc=; b=PJB6PZXgOHV0D5d7q9mP/lyARL1pZXYxFup2lag2r+lsiIPB6rTt6ft4aDeQ7mtJIWG9bb 1fKYeoN5E03KiWOuJOKM7ZLd7K3Ny9h2DgZhRPhNaFTsUPZ2++xv7LGQVkG2H/2Mans21t f/fZ4VYUYjEt+cVqtao1lt4HrdgUS4M= To: Simon Horman <simon.horman@netronome.com> Cc: Jakub Kicinski <kuba@kernel.org>, "David S. Miller" <davem@davemloft.net>, oss-drivers@netronome.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-patchest@linuxtesting.org, trufanov@swemel.ru, vfh@swemel.ru Subject: [PATCH v2] lag_conf: Added pointer check and continue Date: Wed, 16 Nov 2022 11:13:36 +0300 Message-Id: <20221116081336.83373-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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749640408186529797?= X-GMAIL-MSGID: =?utf-8?q?1749640408186529797?= |
Series |
[v2] lag_conf: Added pointer check and continue
|
|
Commit Message
Denis Arefev
Nov. 16, 2022, 8:13 a.m. UTC
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.
Signed-off-by: Denis Arefev <arefev@swemel.ru>
---
drivers/net/ethernet/netronome/nfp/flower/lag_conf.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
Comments
On Wed, Nov 16, 2022 at 11:13:36AM +0300, Denis Arefev wrote: > 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. > > Signed-off-by: Denis Arefev <arefev@swemel.ru> Thanks Denis, I'll let me colleague Yinjun review the functional change, although, based on his earlier feedback, it does look good to me. From my side I have two nits: 1. I think the patch prefix should be 'nfp: flower:' i.e., the patch subject should be more like [PATCH v2] nfp: flower: handle allocation failure in LAG delayed work 2. Inline, below. Kind regards, Simon > 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; 2. I don't think it is necessary (or therefore desirable) to initialise acti_netdevs to NULL. As far as I can tell the variable is already always set before being used. ...
On Wed, Nov 16, 2022 at 10:40:00AM +0100, Simon Horman wrote: > On Wed, Nov 16, 2022 at 11:13:36AM +0300, Denis Arefev wrote: > > 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. > > > > Signed-off-by: Denis Arefev <arefev@swemel.ru> > > Thanks Denis, > > I'll let me colleague Yinjun review the functional change, > although, based on his earlier feedback, it does look good to me. I confirmed with Yinjun that he is happy with the patch, other than the comments that I made. > From my side I have two nits: > > 1. I think the patch prefix should be 'nfp: flower:' > i.e., the patch subject should be more like > [PATCH v2] nfp: flower: handle allocation failure in LAG delayed work > > 2. Inline, below. > > Kind regards, > Simon > > > 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; > > 2. I don't think it is necessary (or therefore desirable) > to initialise acti_netdevs to NULL. > As far as I can tell the variable is already always > set before being used. > > ...
On Wed, 16 Nov 2022 10:39:54 +0100 Simon Horman wrote: > 1. I think the patch prefix should be 'nfp: flower:' > i.e., the patch subject should be more like > [PATCH v2] nfp: flower: handle allocation failure in LAG delayed work One more note here, please add the tree name to the prefix: [PATCH net v2] ... and a fixes tag right above the sign-off: Fixes: bb9a8d031140 ("nfp: flower: monitor and offload LAG groups")
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