netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] mctp: Fix an error handling path in mctp_init()
@ 2022-11-07 15:27 Wei Yongjun
  2022-11-08  1:39 ` Matt Johnston
  2022-11-08  4:26 ` Jakub Kicinski
  0 siblings, 2 replies; 4+ messages in thread
From: Wei Yongjun @ 2022-11-07 15:27 UTC (permalink / raw)
  To: Matt Johnston, Jeremy Kerr, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: Wei Yongjun, netdev

From: Wei Yongjun <weiyongjun1@huawei.com>

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>

diff --git a/net/mctp/af_mctp.c b/net/mctp/af_mctp.c
index b6b5e496fa40..fc9e728b6333 100644
--- a/net/mctp/af_mctp.c
+++ b/net/mctp/af_mctp.c
@@ -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:
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net] mctp: Fix an error handling path in mctp_init()
  2022-11-07 15:27 [PATCH net] mctp: Fix an error handling path in mctp_init() Wei Yongjun
@ 2022-11-08  1:39 ` Matt Johnston
  2022-11-08  4:26 ` Jakub Kicinski
  1 sibling, 0 replies; 4+ messages in thread
From: Matt Johnston @ 2022-11-08  1:39 UTC (permalink / raw)
  To: Wei Yongjun, Jeremy Kerr, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: Wei Yongjun, netdev

On Mon, 2022-11-07 at 15:27 +0000, Wei Yongjun wrote:
> From: Wei Yongjun <weiyongjun1@huawei.com>
> 
> 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>

Thanks for catching that.

Matt

> 
> diff --git a/net/mctp/af_mctp.c b/net/mctp/af_mctp.c
> index b6b5e496fa40..fc9e728b6333 100644
> --- a/net/mctp/af_mctp.c
> +++ b/net/mctp/af_mctp.c
> @@ -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:


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] mctp: Fix an error handling path in mctp_init()
  2022-11-07 15:27 [PATCH net] mctp: Fix an error handling path in mctp_init() Wei Yongjun
  2022-11-08  1:39 ` Matt Johnston
@ 2022-11-08  4:26 ` Jakub Kicinski
  2022-11-08  9:22   ` Wei Yongjun
  1 sibling, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2022-11-08  4:26 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: Matt Johnston, Jeremy Kerr, David S. Miller, Eric Dumazet,
	Paolo Abeni, Wei Yongjun, netdev

On Mon,  7 Nov 2022 15:27:56 +0000 Wei Yongjun wrote:
> +	mctp_routes_exit();

This function is marked as __exit, build complains:

WARNING: modpost: vmlinux.o: section mismatch in reference: mctp_init (section: .init.text) -> mctp_routes_exit (section: .exit.text)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] mctp: Fix an error handling path in mctp_init()
  2022-11-08  4:26 ` Jakub Kicinski
@ 2022-11-08  9:22   ` Wei Yongjun
  0 siblings, 0 replies; 4+ messages in thread
From: Wei Yongjun @ 2022-11-08  9:22 UTC (permalink / raw)
  To: Jakub Kicinski, Wei Yongjun
  Cc: Matt Johnston, Jeremy Kerr, David S. Miller, Eric Dumazet,
	Paolo Abeni, netdev@vger.kernel.org



On 2022/11/8 12:26, Jakub Kicinski wrote:
> On Mon,  7 Nov 2022 15:27:56 +0000 Wei Yongjun wrote:
>> +	mctp_routes_exit();
> 
> This function is marked as __exit, build complains:
> 
> WARNING: modpost: vmlinux.o: section mismatch in reference: mctp_init (section: .init.text) -> mctp_routes_exit (section: .exit.text)

Sorry, it is my fault.

The warning message is flushed by BTF mesages, will fix in
next version.

Thanks,
Wei Yongjun

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-11-08  9:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-07 15:27 [PATCH net] mctp: Fix an error handling path in mctp_init() Wei Yongjun
2022-11-08  1:39 ` Matt Johnston
2022-11-08  4:26 ` Jakub Kicinski
2022-11-08  9:22   ` Wei Yongjun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).