summaryrefslogtreecommitdiff
path: root/net/hsr
diff options
context:
space:
mode:
authorFelix Maurer <fmaurer@redhat.com>2024-03-15 13:04:52 +0100
committerSasha Levin <sashal@kernel.org>2024-03-26 18:21:00 -0400
commit87ca3d940f648bfe49d254fd6bc0c42b552e4af4 (patch)
tree57185e730f24d74f660736178260683529b22bce /net/hsr
parent52287ed416a10bc3d3e204a3186d9509ab3ee634 (diff)
downloadlinux-87ca3d940f648bfe49d254fd6bc0c42b552e4af4.tar.gz
linux-87ca3d940f648bfe49d254fd6bc0c42b552e4af4.tar.bz2
linux-87ca3d940f648bfe49d254fd6bc0c42b552e4af4.zip
hsr: Handle failures in module init
[ 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 Seamless Redundancy protocol (HSRv0)") Signed-off-by: Felix Maurer <fmaurer@redhat.com> Reviewed-by: Shigeru Yoshida <syoshida@redhat.com> Reviewed-by: Breno Leitao <leitao@debian.org> Link: https://lore.kernel.org/r/3ce097c15e3f7ace98fc7fd9bcbf299f092e63d1.1710504184.git.fmaurer@redhat.com Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/hsr')
-rw-r--r--net/hsr/hsr_main.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/net/hsr/hsr_main.c b/net/hsr/hsr_main.c
index b099c3150150..257b50124cee 100644
--- a/net/hsr/hsr_main.c
+++ b/net/hsr/hsr_main.c
@@ -148,14 +148,21 @@ static struct notifier_block hsr_nb = {
static int __init hsr_init(void)
{
- int res;
+ int err;
BUILD_BUG_ON(sizeof(struct hsr_tag) != HSR_HLEN);
- register_netdevice_notifier(&hsr_nb);
- res = hsr_netlink_init();
+ err = register_netdevice_notifier(&hsr_nb);
+ if (err)
+ return err;
+
+ err = hsr_netlink_init();
+ if (err) {
+ unregister_netdevice_notifier(&hsr_nb);
+ return err;
+ }
- return res;
+ return 0;
}
static void __exit hsr_exit(void)