linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hvc_console: prevent wrapping in hvc_console_print()
@ 2009-03-17 12:19 Roel Kluin
  2009-03-30 20:35 ` Andrew Morton
  0 siblings, 1 reply; 14+ messages in thread
From: Roel Kluin @ 2009-03-17 12:19 UTC (permalink / raw)
  To: Andrew Morton; +Cc: lkml

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);

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

end of thread, other threads:[~2009-04-01  0:34 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-17 12:19 [PATCH] hvc_console: prevent wrapping in hvc_console_print() Roel Kluin
2009-03-30 20:35 ` Andrew Morton
2009-03-30 20:55   ` Josh Boyer
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:22           ` Andrew Morton
2009-03-31 21:40             ` Joe Perches
2009-03-31 23:52               ` Josh Boyer
2009-03-31 23:44         ` Michael Ellerman
2009-03-31 23:50           ` Josh Boyer
2009-04-01  0:04             ` Michael Ellerman
2009-04-01  0:20               ` Michael Ellerman
2009-04-01  0:33                 ` Josh Boyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).