mctp: Fix an error handling path in mctp_init()

[ Upstream commit d4072058af ]

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

Fixes: 4d8b931928 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Wei Yongjun 2022-11-08 09:55:17 +00:00 коммит произвёл Greg Kroah-Hartman
Родитель 29961d2332
Коммит 49d8a6e24a
2 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -375,12 +375,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:

Просмотреть файл

@ -1109,7 +1109,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);