Commit 728656506447b3b349d082a7fb99445f9cb0caaa
Committed by
Benjamin Herrenschmidt
1 parent
6826a57d1a
Exists in
master
and in
39 other branches
powerpc/hvsi: Avoid calculating possibly-invalid address
Check whether index is within bounds prior to calculating a possibly-invalid address. Signed-off-by: Roel Kluin <roel.kluin@gmail.com> Cc: Bernd Petrovitsch <bernd@firmix.at> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Showing 1 changed file with 2 additions and 1 deletions Side-by-side Diff
drivers/char/hvsi.c
... | ... | @@ -1230,11 +1230,12 @@ |
1230 | 1230 | |
1231 | 1231 | static int __init hvsi_console_setup(struct console *console, char *options) |
1232 | 1232 | { |
1233 | - struct hvsi_struct *hp = &hvsi_ports[console->index]; | |
1233 | + struct hvsi_struct *hp; | |
1234 | 1234 | int ret; |
1235 | 1235 | |
1236 | 1236 | if (console->index < 0 || console->index >= hvsi_count) |
1237 | 1237 | return -1; |
1238 | + hp = &hvsi_ports[console->index]; | |
1238 | 1239 | |
1239 | 1240 | /* give the FSP a chance to change the baud rate when we re-open */ |
1240 | 1241 | hvsi_close_protocol(hp); |