aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/w1
diff options
context:
space:
mode:
authorDavid Fries <David@Fries.net>2014-01-15 23:29:12 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-02-07 18:40:17 -0500
commit6b355b33a64fd6d8ead2b838ec16fb9b551f71e8 (patch)
treeca153aa21c96bd52126689536b3442f95256a2ee /drivers/w1
parent8a7206a89f85c8439561b0eff85bb9440a2e97a9 (diff)
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: David Fries <David@Fries.net> Cc: stable@vger.kernel.org Acked-by: Evgeniy Polyakov <zbr@ioremap.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/w1')
-rw-r--r--drivers/w1/w1_netlink.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/w1/w1_netlink.c b/drivers/w1/w1_netlink.c
index 40788c925d1c..73705aff53cb 100644
--- a/drivers/w1/w1_netlink.c
+++ b/drivers/w1/w1_netlink.c
@@ -54,28 +54,29 @@ static void w1_send_slave(struct w1_master *dev, u64 rn)
54 struct w1_netlink_msg *hdr = (struct w1_netlink_msg *)(msg + 1); 54 struct w1_netlink_msg *hdr = (struct w1_netlink_msg *)(msg + 1);
55 struct w1_netlink_cmd *cmd = (struct w1_netlink_cmd *)(hdr + 1); 55 struct w1_netlink_cmd *cmd = (struct w1_netlink_cmd *)(hdr + 1);
56 int avail; 56 int avail;
57 u64 *data;
57 58
58 /* update kernel slave list */ 59 /* update kernel slave list */
59 w1_slave_found(dev, rn); 60 w1_slave_found(dev, rn);
60 61
61 avail = dev->priv_size - cmd->len; 62 avail = dev->priv_size - cmd->len;
62 63
63 if (avail > 8) { 64 if (avail < 8) {
64 u64 *data = (void *)(cmd + 1) + cmd->len; 65 msg->ack++;
66 cn_netlink_send(msg, 0, GFP_KERNEL);
65 67
66 *data = rn; 68 msg->len = sizeof(struct w1_netlink_msg) +
67 cmd->len += 8; 69 sizeof(struct w1_netlink_cmd);
68 hdr->len += 8; 70 hdr->len = sizeof(struct w1_netlink_cmd);
69 msg->len += 8; 71 cmd->len = 0;
70 return;
71 } 72 }
72 73
73 msg->ack++; 74 data = (void *)(cmd + 1) + cmd->len;
74 cn_netlink_send(msg, 0, GFP_KERNEL);
75 75
76 msg->len = sizeof(struct w1_netlink_msg) + sizeof(struct w1_netlink_cmd); 76 *data = rn;
77 hdr->len = sizeof(struct w1_netlink_cmd); 77 cmd->len += 8;
78 cmd->len = 0; 78 hdr->len += 8;
79 msg->len += 8;
79} 80}
80 81
81static int w1_process_search_command(struct w1_master *dev, struct cn_msg *msg, 82static int w1_process_search_command(struct w1_master *dev, struct cn_msg *msg,