From: kanoj@google.engr.sgi.com (Kanoj Sarcar)
To: Steven Hand <Steven.Hand@cl.cam.ac.uk>
Cc: Linux-MM@kvack.org
Subject: Re: [PATCH] bugfix for drivers/char/mem.c
Date: Sun, 1 Aug 1999 11:23:30 -0700 (PDT) [thread overview]
Message-ID: <199908011823.LAA32354@google.engr.sgi.com> (raw)
In-Reply-To: <E11AtH4-0003sP-00@heaton.cl.cam.ac.uk> from "Steven Hand" at Aug 1, 99 11:55:09 am
>
> 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;
> }
>
> /*
>
I see the problem. Can I suggest a simpler fix, based on the fact that
vread() returns 0 when count == 0?
- *ppos += p + virtr;
+ *ppos += read + virtr;
Kanoj
--
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/
next prev parent reply other threads:[~1999-08-01 18:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-08-01 10:55 Steven Hand
1999-08-01 18:23 ` Kanoj Sarcar [this message]
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=199908011823.LAA32354@google.engr.sgi.com \
--to=kanoj@google.engr.sgi.com \
--cc=Linux-MM@kvack.org \
--cc=Steven.Hand@cl.cam.ac.uk \
/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