netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tcp_metrics: fix possible memory leak in tcp_metrics_init()
@ 2024-02-15 20:29 kovalev
  2024-02-15 20:34 ` Eric Dumazet
  0 siblings, 1 reply; 2+ messages in thread
From: kovalev @ 2024-02-15 20:29 UTC (permalink / raw)
  To: netdev; +Cc: edumazet, davem, dsahern, kuba, pabeni, ebiederm, kovalev

From: Vasiliy Kovalev <kovalev@altlinux.org>

Fixes: 6493517eaea9 ("tcp_metrics: panic when tcp_metrics_init fails.")
Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
---
 net/ipv4/tcp_metrics.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
index c2a925538542b5..517c7f801dc220 100644
--- a/net/ipv4/tcp_metrics.c
+++ b/net/ipv4/tcp_metrics.c
@@ -1048,6 +1048,8 @@ void __init tcp_metrics_init(void)
 		panic("Could not register tcp_net_metrics_ops\n");
 
 	ret = genl_register_family(&tcp_metrics_nl_family);
-	if (ret < 0)
+	if (ret < 0) {
 		panic("Could not register tcp_metrics generic netlink\n");
+		unregister_pernet_subsys(&tcp_net_metrics_ops);
+	}
 }
-- 
2.33.8


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

* Re: [PATCH] tcp_metrics: fix possible memory leak in tcp_metrics_init()
  2024-02-15 20:29 [PATCH] tcp_metrics: fix possible memory leak in tcp_metrics_init() kovalev
@ 2024-02-15 20:34 ` Eric Dumazet
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Dumazet @ 2024-02-15 20:34 UTC (permalink / raw)
  To: kovalev; +Cc: netdev, davem, dsahern, kuba, pabeni, ebiederm

On Thu, Feb 15, 2024 at 9:29 PM <kovalev@altlinux.org> wrote:
>
> From: Vasiliy Kovalev <kovalev@altlinux.org>
>
> Fixes: 6493517eaea9 ("tcp_metrics: panic when tcp_metrics_init fails.")
> Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
> ---
>  net/ipv4/tcp_metrics.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
> index c2a925538542b5..517c7f801dc220 100644
> --- a/net/ipv4/tcp_metrics.c
> +++ b/net/ipv4/tcp_metrics.c
> @@ -1048,6 +1048,8 @@ void __init tcp_metrics_init(void)
>                 panic("Could not register tcp_net_metrics_ops\n");
>
>         ret = genl_register_family(&tcp_metrics_nl_family);
> -       if (ret < 0)
> +       if (ret < 0) {
>                 panic("Could not register tcp_metrics generic netlink\n");
> +               unregister_pernet_subsys(&tcp_net_metrics_ops);
> +       }
>  }

Well, the whole point of panic() is to crash the host.

We do not expect to recover.

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

end of thread, other threads:[~2024-02-15 20:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-15 20:29 [PATCH] tcp_metrics: fix possible memory leak in tcp_metrics_init() kovalev
2024-02-15 20:34 ` Eric Dumazet

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).