linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bugfix for drivers/char/mem.c
@ 1999-08-01 10:55 Steven Hand
  1999-08-01 18:23 ` Kanoj Sarcar
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Hand @ 1999-08-01 10:55 UTC (permalink / raw)
  To: Linux-MM; +Cc: Steven.Hand

There is a bug in the function read_kmem() in drivers/char/mem.c  -
the file position is incorrectly updated after a read() from /dev/kmem.
This means that successive reads from /dev/kmem without an intervening
seek will return incorrect data. 

The bug has been around for quite a while, and is present in all the
2.2.x kernels.  The following patch (against v.2.3.12) fixes it.


S.

--- v2.3.12/linux/drivers/char/mem.c	Sun Aug  1 11:09:11 1999
+++ linux/drivers/char/mem.c	Sun Aug  1 11:25:07 1999
@@ -245,11 +245,14 @@
 		count -= read;
 	}
 
-	virtr = vread(buf, (char *)p, count);
-	if (virtr < 0)
-		return virtr;
-	*ppos += p + virtr;
-	return virtr + read;
+	if(count) {
+		if((virtr = vread(buf, (char *)p, count)) < 0)
+			return virtr;
+		read += virtr;
+	}
+
+	*ppos += read;
+	return read;
 }
 
 /*


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://humbolt.geo.uu.nl/Linux-MM/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-08-02 13:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-01 10:55 [PATCH] bugfix for drivers/char/mem.c Steven Hand
1999-08-01 18:23 ` Kanoj Sarcar
1999-08-02 13:27   ` Steven Hand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox