[PATCH 14/35] W1: w1_slave_read_id multiple short read bug

From: David Fries
Date: Fri Mar 28 2008 - 08:58:52 EST


This is more to point out the bug in w1_slave_read_id, the next patch
rewrites the routine.

w1.c 1.15
Reading at an offset other than zero, ie reading less than 8 bytes at
a time would result in reading the first bytes over and over until 8
bytes were returned. Added the offset to the buffer.

Signed-off-by: David Fries <david@xxxxxxxxx>
---
drivers/w1/w1.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index b18eedb..dbd9930 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -110,13 +110,13 @@ static ssize_t w1_slave_read_id(struct kobject *kobj,
{
struct w1_slave *sl = kobj_to_w1_slave(kobj);

- if (off > 8) {
+ if (off >= 8) {
count = 0;
} else {
if (off + count > 8)
count = 8 - off;

- memcpy(buf, (u8 *)&sl->reg_num, count);
+ memcpy(buf, (u8 *)&sl->reg_num+off, count);
}

return count;
--
1.4.4.4

Attachment: pgp00000.pgp
Description: PGP signature