public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Fries <David@Fries.net>
To: linux-kernel@vger.kernel.org
Cc: Evgeniy Polyakov <zbr@ioremap.net>, GregKH <greg@kroah.com>
Subject: [PATCH 01/15] w1: fix w1_send_slave dropping a slave id
Date: Wed, 15 Jan 2014 22:29:12 -0600	[thread overview]
Message-ID: <1389846566-28862-2-git-send-email-David@Fries.net> (raw)
In-Reply-To: <1389846566-28862-1-git-send-email-David@Fries.net>

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>
---
 drivers/w1/w1_netlink.c |   25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/w1/w1_netlink.c b/drivers/w1/w1_netlink.c
index 40788c9..73705af 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)
 	struct w1_netlink_msg *hdr = (struct w1_netlink_msg *)(msg + 1);
 	struct w1_netlink_cmd *cmd = (struct w1_netlink_cmd *)(hdr + 1);
 	int avail;
+	u64 *data;
 
 	/* update kernel slave list */
 	w1_slave_found(dev, rn);
 
 	avail = dev->priv_size - cmd->len;
 
-	if (avail > 8) {
-		u64 *data = (void *)(cmd + 1) + cmd->len;
+	if (avail < 8) {
+		msg->ack++;
+		cn_netlink_send(msg, 0, GFP_KERNEL);
 
-		*data = rn;
-		cmd->len += 8;
-		hdr->len += 8;
-		msg->len += 8;
-		return;
+		msg->len = sizeof(struct w1_netlink_msg) +
+			sizeof(struct w1_netlink_cmd);
+		hdr->len = sizeof(struct w1_netlink_cmd);
+		cmd->len = 0;
 	}
 
-	msg->ack++;
-	cn_netlink_send(msg, 0, GFP_KERNEL);
+	data = (void *)(cmd + 1) + cmd->len;
 
-	msg->len = sizeof(struct w1_netlink_msg) + sizeof(struct w1_netlink_cmd);
-	hdr->len = sizeof(struct w1_netlink_cmd);
-	cmd->len = 0;
+	*data = rn;
+	cmd->len += 8;
+	hdr->len += 8;
+	msg->len += 8;
 }
 
 static int w1_process_search_command(struct w1_master *dev, struct cn_msg *msg,
-- 
1.7.10.4


  reply	other threads:[~2014-01-16  4:30 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-16  4:29 [PATCH 00/14] w1: async netlink, search, fixes, and improvements David Fries
2014-01-16  4:29 ` David Fries [this message]
2014-01-16  4:29 ` [PATCH 02/15] w1: fixup search to support abort from netlink David Fries
2014-01-16  4:29 ` [PATCH 03/15] w1: Only wake up the search process if it is going to be searching David Fries
2014-01-16  4:29 ` [PATCH 04/15] w1: increase w1_max_slave_count, allow write access David Fries
2014-01-16  4:29 ` [PATCH 05/15] w1: continue slave search where previous left off David Fries
2014-01-16  4:29 ` [PATCH 06/15] w1: new netlink commands, add/remove/list slaves David Fries
2014-01-16  4:29 ` [PATCH 07/15] w1: process w1 netlink commands in w1_process thread David Fries
2014-01-16  4:29 ` [PATCH 08/15] connector: add portid to unicast in addition to broadcasting David Fries
2014-01-16  4:29 ` [PATCH 09/15] w1: reply only to the requester portid David Fries
2014-01-16  4:29 ` [PATCH 10/15] w1: ds2490 reduce magic numbers David Fries
2014-01-16  4:29 ` [PATCH 11/15] w1: ds2490 USB setup fixes David Fries
2014-01-16  4:29 ` [PATCH 12/15] w1: ds2490 fix and enable hardware search David Fries
2014-01-16  4:29 ` [PATCH 13/15] w1: use family_data instead of rom in w1_slave David Fries
2014-01-16  4:29 ` [PATCH 14/15] w1: format for DocBook and fixes David Fries
2014-01-16  4:29 ` [PATCH 15/15] w1: hold bus_mutex in netlink and search David Fries

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=1389846566-28862-2-git-send-email-David@Fries.net \
    --to=david@fries.net \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zbr@ioremap.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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