Skip to content

Commit 3cf28cd

Browse files
fmaurer-rhPaolo Abeni
authored andcommitted
hsr: Handle failures in module init
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: f421436 ("net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0)") Signed-off-by: Felix Maurer <[email protected]> Reviewed-by: Shigeru Yoshida <[email protected]> Reviewed-by: Breno Leitao <[email protected]> Link: https://lore.kernel.org/r/3ce097c15e3f7ace98fc7fd9bcbf299f092e63d1.1710504184.git.fmaurer@redhat.com Signed-off-by: Paolo Abeni <[email protected]>
1 parent 1422f28 commit 3cf28cd

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

net/hsr/hsr_main.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,21 @@ static struct notifier_block hsr_nb = {
148148

149149
static int __init hsr_init(void)
150150
{
151-
int res;
151+
int err;
152152

153153
BUILD_BUG_ON(sizeof(struct hsr_tag) != HSR_HLEN);
154154

155-
register_netdevice_notifier(&hsr_nb);
156-
res = hsr_netlink_init();
155+
err = register_netdevice_notifier(&hsr_nb);
156+
if (err)
157+
return err;
158+
159+
err = hsr_netlink_init();
160+
if (err) {
161+
unregister_netdevice_notifier(&hsr_nb);
162+
return err;
163+
}
157164

158-
return res;
165+
return 0;
159166
}
160167

161168
static void __exit hsr_exit(void)

0 commit comments

Comments
 (0)