[PATCH 1/5] char: lp: ensure that index has not exceeded LP_NO

From: Shreenidhi Shedi
Date: Sat May 14 2022 - 17:15:53 EST


Signed-off-by: Shreenidhi Shedi <sshedi@xxxxxxxxxx>
---
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 0e22e3b0a04e..d474d02b6c7f 100644
--- a/drivers/char/lp.c
+++ b/drivers/char/lp.c
@@ -972,7 +972,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