From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58D8714FD09; Tue, 16 Jan 2024 19:58:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705435131; cv=none; b=CLZcu1Hk32AfUv5M+yO4cZRFOANV8lz0kxuhKOk2PdXStZn/SujfIjfVC3OyghfoyC1PO+vxXzAULy3/K4Rf7wKEuDPRAleRb45cj7U2zbEdLUnqncsxud0arV8qfbasc+ryWh74+/YRv225SokwEE6EOpoeJOY1ot94O0P2ZZ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705435131; c=relaxed/simple; bh=maqe8tnXGVV5elTannQEiivW4O+i88YHa8LnQjbwlI4=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version:X-stable: X-Patchwork-Hint:X-stable-base:Content-Transfer-Encoding; b=gJW93XPCtz3+5fYPoyzNPUw/ERaE7wtymnLmDJeQSeqMKYwsz5Hm2CUYQKlHt8pTVBZ0h8iAk0/BFgZymQzywf5B2jduxrI+qai6JfxGXQGkZJc30c5ne1yA9ur8mA0OEwF1IJwhjU/k8e4CtK0engs4iYLxxDQ6jXBeSPqsv6M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EK9Rj+W3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EK9Rj+W3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0F44C433A6; Tue, 16 Jan 2024 19:58:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705435131; bh=maqe8tnXGVV5elTannQEiivW4O+i88YHa8LnQjbwlI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EK9Rj+W3Ed9ALlxtAVycv1W87WFjN+XJN9aX++e3q8AMce8+Gx/G0EW//GVNs+Wzw fh1lEEsvabsid3FSFE1sO7oCMYpaJBtVRnsbXBVI5AZPfJ4xqeptlBGowu1smmxvie BdeyTB3oGy9EIAMALCS5PAhbZ3qHFtLvlTaWfaaPiOuFoJLs4cJ13ode/+gmDPgSSZ JV6NhVaASeXJUaBiHdw72KSLn6TR+Cy1sylFI+Cr9Uk44jwwnH7i7m5k28SOsqswiE 71b94HFfqqTNMB+b2mbEKJglf15vsfsW0WalutH/mBVnwyuGHgFZPSvyaqF+C14N5L tDJyjTh5PZhVg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zhengchao Shao , Jay Vosburgh , Paolo Abeni , Sasha Levin , j.vosburgh@gmail.com, andy@greyhouse.net, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 07/47] bonding: return -ENOMEM instead of BUG in alb_upper_dev_walk Date: Tue, 16 Jan 2024 14:57:10 -0500 Message-ID: <20240116195834.257313-7-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240116195834.257313-1-sashal@kernel.org> References: <20240116195834.257313-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.15.147 Content-Transfer-Encoding: 8bit From: Zhengchao Shao [ Upstream commit d6b83f1e3707c4d60acfa58afd3515e17e5d5384 ] If failed to allocate "tags" or could not find the final upper device from start_dev's upper list in bond_verify_device_path(), only the loopback detection of the current upper device should be affected, and the system is no need to be panic. So return -ENOMEM in alb_upper_dev_walk to stop walking, print some warn information when failed to allocate memory for vlan tags in bond_verify_device_path. I also think that the following function calls netdev_walk_all_upper_dev_rcu ---->>>alb_upper_dev_walk ---------->>>bond_verify_device_path >From this way, "end device" can eventually be obtained from "start device" in bond_verify_device_path, IS_ERR(tags) could be instead of IS_ERR_OR_NULL(tags) in alb_upper_dev_walk. Signed-off-by: Zhengchao Shao Acked-by: Jay Vosburgh Link: https://lore.kernel.org/r/20231118081653.1481260-1-shaozhengchao@huawei.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- drivers/net/bonding/bond_alb.c | 3 ++- drivers/net/bonding/bond_main.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index b29393831a30..7091b018078b 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c @@ -973,7 +973,8 @@ static int alb_upper_dev_walk(struct net_device *upper, if (netif_is_macvlan(upper) && !strict_match) { tags = bond_verify_device_path(bond->dev, upper, 0); if (IS_ERR_OR_NULL(tags)) - BUG(); + return -ENOMEM; + alb_send_lp_vid(slave, upper->dev_addr, tags[0].vlan_proto, tags[0].vlan_id); kfree(tags); diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 9aed194d308d..1ecd0c136fc6 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -2893,8 +2893,11 @@ struct bond_vlan_tag *bond_verify_device_path(struct net_device *start_dev, if (start_dev == end_dev) { tags = kcalloc(level + 1, sizeof(*tags), GFP_ATOMIC); - if (!tags) + if (!tags) { + net_err_ratelimited("%s: %s: Failed to allocate tags\n", + __func__, start_dev->name); return ERR_PTR(-ENOMEM); + } tags[level].vlan_proto = VLAN_N_VID; return tags; } -- 2.43.0