Skip to content

Commit e0b7e7d

Browse files
committed
Merge branch 'ipv6-fix-error-path-of-inet6_init'
Sabrina Dubroca says: ==================== ipv6: fix error path of inet6_init() The error path of inet6_init() can trigger multiple kernel panics, mostly due to wrong ordering of cleanups. This series fixes those issues. ==================== Reviewed-by: Xin Long <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2 parents 85eb9af + f707ef6 commit e0b7e7d

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

net/core/rtnetlink.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,10 @@ void rtnl_unregister_all(int protocol)
324324

325325
rtnl_lock();
326326
tab = rtnl_msg_handlers[protocol];
327+
if (!tab) {
328+
rtnl_unlock();
329+
return;
330+
}
327331
RCU_INIT_POINTER(rtnl_msg_handlers[protocol], NULL);
328332
for (msgindex = 0; msgindex < RTM_NR_MSGTYPES; msgindex++) {
329333
link = tab[msgindex];

net/ipv6/af_inet6.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -938,14 +938,14 @@ static int __init inet6_init(void)
938938

939939
err = proto_register(&pingv6_prot, 1);
940940
if (err)
941-
goto out_unregister_ping_proto;
941+
goto out_unregister_raw_proto;
942942

943943
/* We MUST register RAW sockets before we create the ICMP6,
944944
* IGMP6, or NDISC control sockets.
945945
*/
946946
err = rawv6_init();
947947
if (err)
948-
goto out_unregister_raw_proto;
948+
goto out_unregister_ping_proto;
949949

950950
/* Register the family here so that the init calls below will
951951
* be able to create sockets. (?? is this dangerous ??)
@@ -1113,11 +1113,11 @@ static int __init inet6_init(void)
11131113
igmp_fail:
11141114
ndisc_cleanup();
11151115
ndisc_fail:
1116-
ip6_mr_cleanup();
1116+
icmpv6_cleanup();
11171117
icmp_fail:
1118-
unregister_pernet_subsys(&inet6_net_ops);
1118+
ip6_mr_cleanup();
11191119
ipmr_fail:
1120-
icmpv6_cleanup();
1120+
unregister_pernet_subsys(&inet6_net_ops);
11211121
register_pernet_fail:
11221122
sock_unregister(PF_INET6);
11231123
rtnl_unregister_all(PF_INET6);

0 commit comments

Comments
 (0)