Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6629674rwb; Tue, 15 Nov 2022 01:06:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf4X73iXaWujuT5NWindz2vGtSmj/l6JaA8DZA+hdBTUUGJ5RVTT4/UDD0m3M56jUlkn25tH X-Received: by 2002:a17:902:9a48:b0:186:7e8f:54dc with SMTP id x8-20020a1709029a4800b001867e8f54dcmr2964077plv.156.1668503208541; Tue, 15 Nov 2022 01:06:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668503208; cv=none; d=google.com; s=arc-20160816; b=cJKh/HfoAo7e2FO9cBOw8KU9tppxVmqIUaqxT7bjkb1upI2h3jN3EBYD+Wj1ZR7JYQ OU4j0lCEwKIaZpXj3dRwufH7VyZOkiIdALkN+F6gFxOCcXWJUhwI+MhIKyIWlPQLUPmf 1MpZRTOexg+gaRvBtMGNvu7Fn4DVmFZ2600d/2Wd2dxeyjhnolkkjtsDaduvPXWA5dGh 274oNqgV22tnVJMUDNK5vYajpPqsSM6PTnqnkdnBTrnlR/fnm8O0R/DT696aWBglhxq9 5nWX71+9Yc6tgHTliU8GvpJPZPjfsYjgLHjLb1DCRvVRfR9S4pKSnxzX+dCaXfXZQiEz LCQQ== 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=titrkMrDcowcbFHiIEkft2+i/QPFU6J/UtsyULbfVp4=; b=xFqjKMDFVGaoJ5JUczuXwV6JvuWo4rce1PEJ6X+5Q6wgFVQCVHuoSvWTR0VQM0NgCb 9LQ9hgjvpthfzNbV7pVZIdxiJFdgJ6D5p1tgPQItu/ke6aN97Pvx/AjUrs0HQ14PbtUW mvnS62PLNG0ig4dX17ERDI5fwMEtCB0wJgEodxQDTh57zXBRUTDUee1kVxb9h0iBjuaR fQhdjSfvJXwy2kGnJVk+SO6Xmk/dgMzi1nXI7kolp1/gwU+NjjGJ6C99PeSVyM1blv3V 4Bz69dmj0vZRTcEX6hTt9rjvkixQfDoV+GGuOhRKzAlinbv3X9hCqSuha0gRroKxiU+o /wYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@swemel.ru header.s=mail header.b=guilbAL7; 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 t69-20020a638148000000b004752935577asi9496283pgd.229.2022.11.15.01.06.36; Tue, 15 Nov 2022 01:06:48 -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=guilbAL7; 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 S236559AbiKOI5F (ORCPT + 88 others); Tue, 15 Nov 2022 03:57:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232245AbiKOI4p (ORCPT ); Tue, 15 Nov 2022 03:56:45 -0500 Received: from mx.swemel.ru (mx.swemel.ru [95.143.211.150]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8351D1C90E for ; Tue, 15 Nov 2022 00:56:42 -0800 (PST) From: Denis Arefev DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swemel.ru; s=mail; t=1668502598; 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=titrkMrDcowcbFHiIEkft2+i/QPFU6J/UtsyULbfVp4=; b=guilbAL7ooXHiYs7CzcuqZVJ0qvqu6zHiMmzLxPl7XECNmqQQxjdTVRZx8rsoFwAvbFTgU Izlt2TOyjAy3vSKwLyMzJAnxmpNCAeu5Qh0sHyojJfJbRkQybR/jLi5HROpSISYOcFukbN r9KKeu/WrXWwwoE+xXMkSD6WcknjW38= To: Simon Horman Cc: Jakub Kicinski , "David S. Miller" , oss-drivers@netronome.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org, trufanov@swemel.ru, vfh@swemel.ru Subject: [PATCH] lag_conf: Added pointer check Date: Tue, 15 Nov 2022 11:56:37 +0300 Message-Id: <20221115085637.72193-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. Signed-off-by: Denis Arefev --- drivers/net/ethernet/netronome/nfp/flower/lag_conf.c | 4 +++- 1 file changed, 3 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..95ba6e92197d 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,8 @@ 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) + break; /* Include sanity check in the loop. It may be that a bond has * changed between processing the last notification and the -- 2.25.1