Commit 6b355b33 authored by David Fries's avatar David Fries Committed by Greg Kroah-Hartman

w1: fix w1_send_slave dropping a slave id

Previous logic,
if (avail > 8) {
	store slave;
	return;
}
send data; clear;

The logic error is, if there isn't space send the buffer and clear,
but the slave wasn't added to the now empty buffer loosing that slave
id.  It also should have been "if (avail >= 8)" because when it is 8,
there is space.

Instead, if there isn't space send and clear the buffer, then there is
always space for the slave id.
Signed-off-by: default avatarDavid Fries <David@Fries.net>
Cc: stable@vger.kernel.org
Acked-by: default avatarEvgeniy Polyakov <zbr@ioremap.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8a7206a8
...@@ -54,28 +54,29 @@ static void w1_send_slave(struct w1_master *dev, u64 rn) ...@@ -54,28 +54,29 @@ static void w1_send_slave(struct w1_master *dev, u64 rn)
struct w1_netlink_msg *hdr = (struct w1_netlink_msg *)(msg + 1); struct w1_netlink_msg *hdr = (struct w1_netlink_msg *)(msg + 1);
struct w1_netlink_cmd *cmd = (struct w1_netlink_cmd *)(hdr + 1); struct w1_netlink_cmd *cmd = (struct w1_netlink_cmd *)(hdr + 1);
int avail; int avail;
u64 *data;
/* update kernel slave list */ /* update kernel slave list */
w1_slave_found(dev, rn); w1_slave_found(dev, rn);
avail = dev->priv_size - cmd->len; avail = dev->priv_size - cmd->len;
if (avail > 8) { if (avail < 8) {
u64 *data = (void *)(cmd + 1) + cmd->len; msg->ack++;
cn_netlink_send(msg, 0, GFP_KERNEL);
*data = rn; msg->len = sizeof(struct w1_netlink_msg) +
cmd->len += 8; sizeof(struct w1_netlink_cmd);
hdr->len += 8; hdr->len = sizeof(struct w1_netlink_cmd);
msg->len += 8; cmd->len = 0;
return;
} }
msg->ack++; data = (void *)(cmd + 1) + cmd->len;
cn_netlink_send(msg, 0, GFP_KERNEL);
msg->len = sizeof(struct w1_netlink_msg) + sizeof(struct w1_netlink_cmd); *data = rn;
hdr->len = sizeof(struct w1_netlink_cmd); cmd->len += 8;
cmd->len = 0; hdr->len += 8;
msg->len += 8;
} }
static int w1_process_search_command(struct w1_master *dev, struct cn_msg *msg, static int w1_process_search_command(struct w1_master *dev, struct cn_msg *msg,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment