Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp582524lqi; Thu, 7 Mar 2024 06:11:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUm+XGet9No3X04bQwfmg4d+AG7msgq682qBt+yT0ivNv6iOMY1VFjZvLRBdjCxOv+Oz6k7fzNyYUXqOT5TOiz8cSPUto6ZcqDJUAXoBA== X-Google-Smtp-Source: AGHT+IFVS31WeoCKTMAlgpFUU71lcz0MelojakTFd228sltXTR1h9dVvwSAvsWLDtUwRjWQQj2I7 X-Received: by 2002:a17:903:22c1:b0:1db:cb54:5e77 with SMTP id y1-20020a17090322c100b001dbcb545e77mr10825394plg.22.1709820697632; Thu, 07 Mar 2024 06:11:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709820697; cv=pass; d=google.com; s=arc-20160816; b=sAXSVRMcIWaN0rMwbUcBXJ7hoGq1dU55SubhAP92o/kwtKtS4X//OtDdE+xXNR0fp+ lCq+RfuXOZpxqpTMP0mLR0rPcfQmvB3M/bq12KZiNUp2U1umtmY64tioUXJpi/Tt0n7p TZRUOlguyz+04DhTd4t6DIWujgvkUN3YJvwRmpZc4X1kL1E9as00SCkan3O37eRgWHy4 a6GLXNORN4nqfR6BMITUvwDYmOiMyD36lWSgl0ymia6e6P0u8A4uJYQ5j1wWTAByvfkB bH2L4KKNLUI235643qvFudQC4zjfrkfzIZ4zmPfqM0OmsFsNYmcK4sEb7R9HISAJuuhl mTAA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from; bh=Gxf+gf/HM7qdTP/3FA/KliFMeWpgDob/iR9WLcqCe/4=; fh=HBHFZq/01fLCtMLY76WgzFnqOTXIkWFIdJ9EK6eT6v0=; b=AifALhQH7RdYgl67P8ukdnxHu4/73NCTZt9qV7xVlYGrhF93++gEEd33kAUyBx19ag YE3f1iW3kv4Gf5Ff1JRZbnTgHOMvlH1e1xFqy7waiYiWInc7qYeQ8y6X1mDQSe/lP5GY Gp+ABhIHajM5vZygXViSDFDccuaSEa1rCxzKFbhFNk2RYvEO3mx2JKdkj7ABsnOVtAwT rNa98a87lPMSC/qESyK8g7xa0bO7kmBS7n5wskk2vze3rKa2QKKcAtvg2LLPuZRb/TrO jmmpyajAXu/ZSKmhl0pNFcnvR5otEbeUddMPHRhrTmv7MOLmDkCCK71LtbVkD3MmxsI+ UNFw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=zju.edu.cn); spf=pass (google.com: domain of linux-kernel+bounces-95667-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95667-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q9-20020a17090311c900b001dc76ff8904si7538253plh.540.2024.03.07.06.11.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 06:11:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95667-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=zju.edu.cn); spf=pass (google.com: domain of linux-kernel+bounces-95667-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95667-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5A9A0B23E90 for ; Thu, 7 Mar 2024 13:54:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7C5F012D765; Thu, 7 Mar 2024 13:54:12 +0000 (UTC) Received: from azure-sdnproxy.icoremail.net (azure-sdnproxy.icoremail.net [52.237.72.81]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A2A0B12B154; Thu, 7 Mar 2024 13:54:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.237.72.81 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709819652; cv=none; b=Ij8o8yLOcjqtyjUPqDJrePcWFrDMV0w+xn2IZcPMe3s8x7yA/4K3Lv+K76yNY8d/tFE46HZK2xaqn8rQbHLX7a1noQlyOnD95FX42IraJnPoUsSwlCC2AXxK7C0mqEV9zof6SebWQ4IcrJxCCCDLyMmr26syWQC7fsgNF/6Gpg8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709819652; c=relaxed/simple; bh=1rXdRG/mrYNFZsk4vvEvOgen0D6usXjQoOIkIJ9EU8A=; h=From:To:Cc:Subject:Date:Message-Id; b=CrFhvfS1URDBkuGrxyxIz5+1KNgQKu18JEZEGzNIggr6zcw4K1OzY2up3uZP4GKgHMwn2OsVtiytkit+oZlLTDgjAlFCxAaH7RdmUhK+cxzBf0clvD8YBPuc4SlLBJh+lwpIsQ5781jNp+IrA6hQcaeIgn/aAWqalU29Jewr9GQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zju.edu.cn; spf=pass smtp.mailfrom=zju.edu.cn; arc=none smtp.client-ip=52.237.72.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zju.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zju.edu.cn Received: from ubuntu.localdomain (unknown [106.117.76.127]) by mail-app4 (Coremail) with SMTP id cS_KCgCHHcPfxulloikAAA--.553S2; Thu, 07 Mar 2024 21:53:44 +0800 (CST) From: Duoming Zhou To: linux-kernel@vger.kernel.org Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, christophe.jaillet@wanadoo.fr, horms@kernel.org, pabeni@redhat.com, edumazet@google.com, davem@davemloft.net, kuba@kernel.org, louis.peens@corigine.com, Duoming Zhou Subject: [PATCH] nfp: flower: handle acti_netdevs allocation failure Date: Thu, 7 Mar 2024 21:53:35 +0800 Message-Id: <20240307135335.19306-1-duoming@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID:cS_KCgCHHcPfxulloikAAA--.553S2 X-Coremail-Antispam: 1UD129KBjvJXoW7tFy7Zw4DWr15tr4fCw1kuFg_yoW8GrWxpF WDGFyUZa1kJw13ta1UJw4IgFyF9a4vqFyjgF1fAws5uF9Yq3ZrKrs5KFWUG3WYyrWrG3Wf ZFWYva47WF1kG3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9a14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AKxV W8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xf McIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7 v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF 7I0E8cxan2IY04v7MxkF7I0En4kS14v26r1q6r43MxAIw28IcxkI7VAKI48JMxC20s026x CaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_ JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r 1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_ Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8Jr UvcSsGvfC2KfnxnUUI43ZEXa7VUbGQ6JUUUUU== X-CM-SenderInfo: qssqjiasttq6lmxovvfxof0/1tbiAwINAWXou1MR+gA3s0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The kmalloc_array() in nfp_fl_lag_do_work() will return null, if the physical memory has run out. As a result, if we dereference the acti_netdevs, the null pointer dereference bugs will happen. This patch adds a check to judge whether allocation failure occurs. If it happens, the delayed work will be rescheduled and try again. Fixes: bb9a8d031140 ("nfp: flower: monitor and offload LAG groups") Signed-off-by: Duoming Zhou --- drivers/net/ethernet/netronome/nfp/flower/lag_conf.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ethernet/netronome/nfp/flower/lag_conf.c b/drivers/net/ethernet/netronome/nfp/flower/lag_conf.c index 361d7c495e2..07759296c71 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/lag_conf.c +++ b/drivers/net/ethernet/netronome/nfp/flower/lag_conf.c @@ -337,6 +337,13 @@ 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) { + nfp_flower_cmsg_warn(priv->app, + "memory allocate failed\n"); + 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.17.1