From: Andrew Morton <akpm@linux-foundation.org>
To: Roel Kluin <roel.kluin@gmail.com>
Cc: linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] hvc_console: prevent wrapping in hvc_console_print()
Date: Mon, 30 Mar 2009 13:35:31 -0700 [thread overview]
Message-ID: <20090330133531.f5d99c09.akpm@linux-foundation.org> (raw)
In-Reply-To: <49BF956B.9030109@gmail.com>
On Tue, 17 Mar 2009 13:19:55 +0100
Roel Kluin <roel.kluin@gmail.com> wrote:
> This was found by code analysis, is it needed?
> ------------------------------>8-------------8<---------------------------------
> If we subtract too much on unsigned i it wraps.
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
> index 94e7e3c..d06313c 100644
> --- a/drivers/char/hvc_console.c
> +++ b/drivers/char/hvc_console.c
> @@ -161,10 +161,10 @@ static void hvc_console_print(struct console *co, const char *b,
> }
> } else {
> r = cons_ops[index]->put_chars(vtermnos[index], c, i);
> - if (r <= 0) {
> + if (r <= 0 || r > i) {
> /* throw away chars on error */
> i = 0;
> - } else if (r > 0) {
> + } else {
> i -= r;
> if (i > 0)
> memmove(c, c+r, i);
I expect that ->put_chars() will either return a -ve errno or will
return the number of chars which were written, which will be less than
or equal to `i'.
Or maybe I miss your point.
Guys, could we have a MAINTAINERS entry for this driver please?
WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org>
To: Roel Kluin <roel.kluin@gmail.com>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@ozlabs.org
Subject: Re: [PATCH] hvc_console: prevent wrapping in hvc_console_print()
Date: Mon, 30 Mar 2009 13:35:31 -0700 [thread overview]
Message-ID: <20090330133531.f5d99c09.akpm@linux-foundation.org> (raw)
In-Reply-To: <49BF956B.9030109@gmail.com>
On Tue, 17 Mar 2009 13:19:55 +0100
Roel Kluin <roel.kluin@gmail.com> wrote:
> This was found by code analysis, is it needed?
> ------------------------------>8-------------8<---------------------------------
> If we subtract too much on unsigned i it wraps.
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
> index 94e7e3c..d06313c 100644
> --- a/drivers/char/hvc_console.c
> +++ b/drivers/char/hvc_console.c
> @@ -161,10 +161,10 @@ static void hvc_console_print(struct console *co, const char *b,
> }
> } else {
> r = cons_ops[index]->put_chars(vtermnos[index], c, i);
> - if (r <= 0) {
> + if (r <= 0 || r > i) {
> /* throw away chars on error */
> i = 0;
> - } else if (r > 0) {
> + } else {
> i -= r;
> if (i > 0)
> memmove(c, c+r, i);
I expect that ->put_chars() will either return a -ve errno or will
return the number of chars which were written, which will be less than
or equal to `i'.
Or maybe I miss your point.
Guys, could we have a MAINTAINERS entry for this driver please?
next prev parent reply other threads:[~2009-03-30 20:37 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-17 12:19 [PATCH] hvc_console: prevent wrapping in hvc_console_print() Roel Kluin
2009-03-30 20:35 ` Andrew Morton [this message]
2009-03-30 20:35 ` Andrew Morton
2009-03-30 20:55 ` Josh Boyer
2009-03-30 20:55 ` Josh Boyer
2009-03-30 21:18 ` Andrew Morton
2009-03-30 21:18 ` Andrew Morton
2009-03-31 13:29 ` [PATCH] Add hvc_console to MAINTAINERS Josh Boyer
2009-03-31 21:10 ` Joe Perches
2009-03-31 21:10 ` Joe Perches
2009-03-31 21:22 ` Andrew Morton
2009-03-31 21:22 ` Andrew Morton
2009-03-31 21:40 ` Joe Perches
2009-03-31 21:40 ` Joe Perches
2009-03-31 23:52 ` Josh Boyer
2009-03-31 23:52 ` Josh Boyer
2009-03-31 23:44 ` Michael Ellerman
2009-03-31 23:44 ` Michael Ellerman
2009-03-31 23:50 ` Josh Boyer
2009-03-31 23:50 ` Josh Boyer
2009-04-01 0:04 ` Michael Ellerman
2009-04-01 0:04 ` Michael Ellerman
2009-04-01 0:20 ` Michael Ellerman
2009-04-01 0:33 ` Josh Boyer
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=20090330133531.f5d99c09.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=roel.kluin@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.