linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Steven Hand <Steven.Hand@cl.cam.ac.uk>
To: Linux-MM@kvack.org
Cc: Steven.Hand@cl.cam.ac.uk
Subject: [PATCH] bugfix for drivers/char/mem.c
Date: Sun, 01 Aug 1999 11:55:09 +0100	[thread overview]
Message-ID: <E11AtH4-0003sP-00@heaton.cl.cam.ac.uk> (raw)

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/

             reply	other threads:[~1999-08-01 10:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-01 10:55 Steven Hand [this message]
1999-08-01 18:23 ` Kanoj Sarcar
1999-08-02 13:27   ` Steven Hand

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=E11AtH4-0003sP-00@heaton.cl.cam.ac.uk \
    --to=steven.hand@cl.cam.ac.uk \
    --cc=Linux-MM@kvack.org \
    /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