Commit d4072058 authored by Wei Yongjun's avatar Wei Yongjun Committed by Jakub Kicinski
Browse files

mctp: Fix an error handling path in mctp_init()



If mctp_neigh_init() return error, the routes resources should
be released in the error handling path. Otherwise some resources
leak.

Fixes: 4d8b9319 ("mctp: Add neighbour implementation")
Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
Acked-by: default avatarMatt Johnston <matt@codeconstruct.com.au>
Link: https://lore.kernel.org/r/20221108095517.620115-1-weiyongjun@huaweicloud.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent dcea1a81
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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:
+1 −1
Original line number Diff line number Diff line
@@ -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);