linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] char: lp: ensure that index has not exceeded LP_NO
@ 2022-05-15  7:54 Shreenidhi Shedi
  2022-05-15  7:54 ` [PATCH 2/3] char: lp: remove redundant initialization of err Shreenidhi Shedi
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Shreenidhi Shedi @ 2022-05-15  7:54 UTC (permalink / raw)
  To: arnd, gregkh; +Cc: linux-kernel, yesshedi, Shreenidhi Shedi

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


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

end of thread, other threads:[~2022-06-03 12:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-15  7:54 [PATCH 1/3] char: lp: ensure that index has not exceeded LP_NO Shreenidhi Shedi
2022-05-15  7:54 ` [PATCH 2/3] char: lp: remove redundant initialization of err Shreenidhi Shedi
2022-05-15  8:08   ` Greg KH
2022-05-15  7:54 ` [PATCH 3/3] char: lp: fix most of checkspec.pl warnings & errors Shreenidhi Shedi
2022-05-15  8:08   ` Greg KH
2022-05-15  8:07 ` [PATCH 1/3] char: lp: ensure that index has not exceeded LP_NO Greg KH
2022-06-03 11:57 ` Shreenidhi Shedi
2022-06-03 12:02   ` Shreenidhi Shedi
2022-06-03 12:44     ` Greg KH
2022-06-03 12:49       ` Shreenidhi Shedi

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