]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mctp: Fix an error handling path in mctp_init()
authorWei Yongjun <weiyongjun1@huawei.com>
Tue, 8 Nov 2022 09:55:17 +0000 (09:55 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 10 Nov 2022 03:26:08 +0000 (19:26 -0800)
If mctp_neigh_init() return error, the routes resources should
be released in the error handling path. Otherwise some resources
leak.

Fixes: 4d8b9319282a ("mctp: Add neighbour implementation")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Acked-by: Matt Johnston <matt@codeconstruct.com.au>
Link: https://lore.kernel.org/r/20221108095517.620115-1-weiyongjun@huaweicloud.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/mctp/af_mctp.c
net/mctp/route.c

index b6b5e496fa403cc94331d3efbf1ba1dcbc405110..fc9e728b6333a1f126d8ac615e28fb66028217bc 100644 (file)
@@ -665,12 +665,14 @@ static __init int mctp_init(void)
 
        rc = mctp_neigh_init();
        if (rc)
-               goto err_unreg_proto;
+               goto err_unreg_routes;
 
        mctp_device_init();
 
        return 0;
 
+err_unreg_routes:
+       mctp_routes_exit();
 err_unreg_proto:
        proto_unregister(&mctp_proto);
 err_unreg_sock:
index 2155f15a074cd10649a4e7e09ce0dba3acc66f72..f9a80b82dc511dbcde9e116838702259c7765759 100644 (file)
@@ -1400,7 +1400,7 @@ int __init mctp_routes_init(void)
        return register_pernet_subsys(&mctp_net_ops);
 }
 
-void __exit mctp_routes_exit(void)
+void mctp_routes_exit(void)
 {
        unregister_pernet_subsys(&mctp_net_ops);
        rtnl_unregister(PF_MCTP, RTM_DELROUTE);