Messages in this thread Patch in this message | | | From | Shreenidhi Shedi <> | Subject | [PATCH 1/3] char: lp: ensure that index has not exceeded LP_NO | Date | Sun, 15 May 2022 13:24:53 +0530 |
| |
After finishing the loop, index value can be equal to LP_NO and lp_table array is of size LP_NO, so this can end up in accessing an out of bound address in lp_register function.
Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com> --- drivers/char/lp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/char/lp.c b/drivers/char/lp.c index bd95aba1f..e61060f3c 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c @@ -971,7 +971,7 @@ static void lp_attach(struct parport *port) if (port_num[i] == -1) break; - if (!lp_register(i, port)) + if (i < LP_NO && !lp_register(i, port)) lp_count++; break; -- 2.36.1
| |