From: Jakub Kicinski <kuba@kernel•org>
To: davem@davemloft•net
Cc: netdev@vger•kernel.org, edumazet@google•com, pabeni@redhat•com,
chuck.lever@oracle•com, jiri@resnulli•us,
nicolas.dichtel@6wind•com, willemb@google•com,
Jakub Kicinski <kuba@kernel•org>
Subject: [PATCH net v2 2/2] tools: ynl: don't leak mcast_groups on init error
Date: Tue, 20 Feb 2024 08:11:12 -0800 [thread overview]
Message-ID: <20240220161112.2735195-3-kuba@kernel.org> (raw)
In-Reply-To: <20240220161112.2735195-1-kuba@kernel.org>
Make sure to free the already-parsed mcast_groups if
we don't get an ack from the kernel when reading family info.
This is part of the ynl_sock_create() error path, so we won't
get a call to ynl_sock_destroy() to free them later.
Fixes: 86878f14d71a ("tools: ynl: user space helpers")
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind•com>
Signed-off-by: Jakub Kicinski <kuba@kernel•org>
---
CC: nicolas.dichtel@6wind•com
CC: willemb@google•com
---
tools/net/ynl/lib/ynl.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/net/ynl/lib/ynl.c b/tools/net/ynl/lib/ynl.c
index 9e41c8c0cc99..6e6d474c8366 100644
--- a/tools/net/ynl/lib/ynl.c
+++ b/tools/net/ynl/lib/ynl.c
@@ -588,7 +588,13 @@ static int ynl_sock_read_family(struct ynl_sock *ys, const char *family_name)
return err;
}
- return ynl_recv_ack(ys, err);
+ err = ynl_recv_ack(ys, err);
+ if (err < 0) {
+ free(ys->mcast_groups);
+ return err;
+ }
+
+ return 0;
}
struct ynl_sock *
--
2.43.0
next prev parent reply other threads:[~2024-02-20 16:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-20 16:11 [PATCH net v2 0/2] tools: ynl: fix impossible errors Jakub Kicinski
2024-02-20 16:11 ` [PATCH net v2 1/2] tools: ynl: make sure we always pass yarg to mnl_cb_run Jakub Kicinski
2024-02-20 16:11 ` Jakub Kicinski [this message]
2024-02-22 1:20 ` [PATCH net v2 0/2] tools: ynl: fix impossible errors patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240220161112.2735195-3-kuba@kernel.org \
--to=kuba@kernel$(echo .)org \
--cc=chuck.lever@oracle$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=edumazet@google$(echo .)com \
--cc=jiri@resnulli$(echo .)us \
--cc=netdev@vger$(echo .)kernel.org \
--cc=nicolas.dichtel@6wind$(echo .)com \
--cc=pabeni@redhat$(echo .)com \
--cc=willemb@google$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox