Skip to contentSkip to conversation

powerpc: avoid calculating possibly-invalid address

PATCH Applied [email protected] 1 participant 1 message Aug 6, 2009 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 powerpc: avoid calculating possibly-invalid address

From: Roel Kluin <[email protected]>

Check whether index is within bounds prior to calculating a possibly-invalid address.

Cc Bernd Petrovitsch <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>

---

 drivers/char/hvsi.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/hvsi.c renamed from drivers/char/hvsi.c~powerpc-avoid-calculating-possibly-invalid-address +2 -1
diff -puN drivers/char/hvsi.c~powerpc-avoid-calculating-possibly-invalid-address drivers/char/hvsi.c
@@ -1230,11 +1230,12 @@ static struct tty_driver *hvsi_console_d
 
 static int __init hvsi_console_setup(struct console *console, char *options)
 {
-	struct hvsi_struct *hp = &hvsi_ports[console->index];
+	struct hvsi_struct *hp;
 	int ret;
 
 	if (console->index < 0 || console->index >= hvsi_count)
 		return -1;
+	hp = &hvsi_ports[console->index];
 
 	/* give the FSP a chance to change the baud rate when we re-open */
 	hvsi_close_protocol(hp);

_