mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-01 02:27:51 -04:00
Merge branch 'tools-ynl-fix-impossible-errors'
Jakub Kicinski says: ==================== tools: ynl: fix impossible errors Fix bugs discovered while I was hacking in low level stuff in YNL and kept breaking the socket, exercising the "impossible" error paths. v1: https://lore.kernel.org/all/20240217001742.2466993-1-kuba@kernel.org/ ==================== Link: https://lore.kernel.org/r/20240220161112.2735195-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
@@ -466,6 +466,8 @@ ynl_gemsg_start_dump(struct ynl_sock *ys, __u32 id, __u8 cmd, __u8 version)
|
||||
|
||||
int ynl_recv_ack(struct ynl_sock *ys, int ret)
|
||||
{
|
||||
struct ynl_parse_arg yarg = { .ys = ys, };
|
||||
|
||||
if (!ret) {
|
||||
yerr(ys, YNL_ERROR_EXPECT_ACK,
|
||||
"Expecting an ACK but nothing received");
|
||||
@@ -478,7 +480,7 @@ int ynl_recv_ack(struct ynl_sock *ys, int ret)
|
||||
return ret;
|
||||
}
|
||||
return mnl_cb_run(ys->rx_buf, ret, ys->seq, ys->portid,
|
||||
ynl_cb_null, ys);
|
||||
ynl_cb_null, &yarg);
|
||||
}
|
||||
|
||||
int ynl_cb_null(const struct nlmsghdr *nlh, void *data)
|
||||
@@ -586,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 *
|
||||
@@ -741,11 +749,14 @@ static int ynl_ntf_parse(struct ynl_sock *ys, const struct nlmsghdr *nlh)
|
||||
|
||||
static int ynl_ntf_trampoline(const struct nlmsghdr *nlh, void *data)
|
||||
{
|
||||
return ynl_ntf_parse((struct ynl_sock *)data, nlh);
|
||||
struct ynl_parse_arg *yarg = data;
|
||||
|
||||
return ynl_ntf_parse(yarg->ys, nlh);
|
||||
}
|
||||
|
||||
int ynl_ntf_check(struct ynl_sock *ys)
|
||||
{
|
||||
struct ynl_parse_arg yarg = { .ys = ys, };
|
||||
ssize_t len;
|
||||
int err;
|
||||
|
||||
@@ -767,7 +778,7 @@ int ynl_ntf_check(struct ynl_sock *ys)
|
||||
return len;
|
||||
|
||||
err = mnl_cb_run2(ys->rx_buf, len, ys->seq, ys->portid,
|
||||
ynl_ntf_trampoline, ys,
|
||||
ynl_ntf_trampoline, &yarg,
|
||||
ynl_cb_array, NLMSG_MIN_TYPE);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
Reference in New Issue
Block a user