From nobody Fri Dec 19 20:14:36 2025 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 E2C73182F08; Sun, 24 Mar 2024 23:49:44 +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=1711324186; cv=none; b=cC0qo4gSkCgC/MeS9g7TjRNObBt6imz9UhF6kAIpYdzDiIfNdxziAR+oWD28c/cTBXh3NJFdemhdHWoOy55JUn6Qm2YTJC354ZEHAADIL6PL4igRWxlrhljaR6NV8wOGncQ/yVqIsAaLiqUmYSSbM/05XE+Knav6AMJYlLnogFQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711324186; c=relaxed/simple; bh=WKRm0SsyDJX7e+dk7G/AvnUAR+AksSTMbih9I2vwC+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YhqdnuXcyzeot+j2j0w0p/ksWDdMr1fnH+RuUxwiRanmfAwUu2ukU8yj5CNOhosAidnN77sKun3Om8SywJhk2uggVFkqX5qXGQG3M/QjW6BFdotxs8LpeQgKnLfQRXF2axEU+Z2RIyO753Xf5iZyHqkRiSURvHDWuog60IAyT6Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bFt9C6jR; 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="bFt9C6jR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1C71C433F1; Sun, 24 Mar 2024 23:49:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711324184; bh=WKRm0SsyDJX7e+dk7G/AvnUAR+AksSTMbih9I2vwC+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bFt9C6jRz17Jt31GLn//+F6N4Ik9/1+1ayqEVSEMk3XaFVDvrZ03Yk/7oEfrRGDTJ S3ZY0d5ubDvYuPV2Gl5R4V9Ktp2rzULyq1kKMKOSCb7aidnkeDcW5cDMxAnDaGpT7j YQtaEGRG79W2FpFtfnplYJshMzNizZeoDrs87QUeAtyUZHjhtLAy0w/4QjI/v2VJnb dLr1XbutU0f7lKWLy+nCrdo/F8RBzjIjX6WWE4dc1qheVUNZfU7WVZ9ERXkCEbr8Ry SFpesB9K6LIeyTq6mbnTm23+SzBCMVwQGg+jxZDkGkZqaRpz5m3zPGO/dOEz7Q9HbS p3/s+yHm97ikA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Felix Maurer , Shigeru Yoshida , Breno Leitao , Paolo Abeni , Sasha Levin Subject: [PATCH 5.4 174/183] hsr: Handle failures in module init Date: Sun, 24 Mar 2024 19:46:27 -0400 Message-ID: <20240324234638.1355609-175-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324234638.1355609-1-sashal@kernel.org> References: <20240324234638.1355609-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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Felix Maurer [ Upstream commit 3cf28cd492308e5f63ed00b29ea03ca016264376 ] A failure during registration of the netdev notifier was not handled at all. A failure during netlink initialization did not unregister the netdev notifier. Handle failures of netdev notifier registration and netlink initialization. Both functions should only return negative values on failure and thereby lead to the hsr module not being loaded. Fixes: f421436a591d ("net/hsr: Add support for the High-availability Seamle= ss Redundancy protocol (HSRv0)") Signed-off-by: Felix Maurer Reviewed-by: Shigeru Yoshida Reviewed-by: Breno Leitao Link: https://lore.kernel.org/r/3ce097c15e3f7ace98fc7fd9bcbf299f092e63d1.17= 10504184.git.fmaurer@redhat.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/hsr/hsr_main.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/net/hsr/hsr_main.c b/net/hsr/hsr_main.c index 9e389accbfc7e..ea627e532aab8 100644 --- a/net/hsr/hsr_main.c +++ b/net/hsr/hsr_main.c @@ -113,14 +113,21 @@ static struct notifier_block hsr_nb =3D { =20 static int __init hsr_init(void) { - int res; + int err; =20 BUILD_BUG_ON(sizeof(struct hsr_tag) !=3D HSR_HLEN); =20 - register_netdevice_notifier(&hsr_nb); - res =3D hsr_netlink_init(); + err =3D register_netdevice_notifier(&hsr_nb); + if (err) + return err; + + err =3D hsr_netlink_init(); + if (err) { + unregister_netdevice_notifier(&hsr_nb); + return err; + } =20 - return res; + return 0; } =20 static void __exit hsr_exit(void) --=20 2.43.0