Skip to content

Commit

Permalink
tools: ynl: don't leak mcast_groups on init error
Browse files Browse the repository at this point in the history
[ Upstream commit 5d78b73 ]

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: 86878f1 ("tools: ynl: user space helpers")
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Link: https://lore.kernel.org/r/20240220161112.2735195-3-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
kuba-moo authored and gregkh committed Mar 1, 2024
1 parent 91addaf commit a702e98
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tools/net/ynl/lib/ynl.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,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 *
Expand Down

0 comments on commit a702e98

Please sign in to comment.