Skip to contentSkip to conversation

Input: ads7846 - Expand xfer array to match usage

PATCH In review Kees Cook 3 participants 4 messages Nov 17, 2024 – Nov 18, 2024

Subsystems (2)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 Input: ads7846 - Expand xfer array to match usage

Commit 781a07da9bb9 ("Input: ads7846 - add dummy command register clearing cycle") added commands to struct ser_req::xfer without expanding it to hold them. Expand the array to the correct size.

../drivers/input/touchscreen/ads7846.c: In function 'ads7846_read12_ser':
../drivers/input/touchscreen/ads7846.c:416:18: error: array subscript 7 is above array bounds of 'struct spi_transfer[6]' [-Werror=array-bounds=]

  416 |         req->xfer[7].rx_buf = &req->scratch;
      |         ~~~~~~~~~^~~
../drivers/input/touchscreen/ads7846.c:334:33: note: while referencing 'xfer'
  334 |         struct spi_transfer     xfer[6];
      |                                 ^~~~
Fixes 781a07da9bb9 ("Input: ads7846 - add dummy command register clearing cycle")

---
Cc: Dmitry Torokhov <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Luca Ellero <[email protected]>
Cc: [email protected]

---
 drivers/input/touchscreen/ads7846.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/ads7846.c +1 -1
index 75e5b2e4368d..066dc04003fa 100644
@@ -331,7 +331,7 @@ struct ser_req {
 	u8			ref_off;
 	u16			scratch;
 	struct spi_message	msg;
-	struct spi_transfer	xfer[6];
+	struct spi_transfer	xfer[8];
 	/*
 	 * DMA (thus cache coherency maintenance) requires the
 	 * transfer buffers to live in their own cache lines.
Signature · 1 line
2.34.1
#1 lore raw
Quoted 6 lines · Kees Cook

Commit 781a07da9bb9 ("Input: ads7846 - add dummy command register clearing cycle") added commands to struct ser_req::xfer without expanding it to hold them. Expand the array to the correct size.

../drivers/input/touchscreen/ads7846.c: In function 'ads7846_read12_ser':
../drivers/input/touchscreen/ads7846.c:416:18: error: array subscript 7 is above array bounds of 'struct spi_transfer[6]' [-Werror=array-bounds=]

Quoted 8 lines
   416 |         req->xfer[7].rx_buf = &req->scratch;
       |         ~~~~~~~~~^~~
../drivers/input/touchscreen/ads7846.c:334:33: note: while referencing 'xfer'
   334 |         struct spi_transfer     xfer[6];
       |                                 ^~~~
Fixes 781a07da9bb9 ("Input: ads7846 - add dummy command register clearing cycle")

I think Nathan already sent a fix too.

Thanks !

author
#2 lore raw
Quoted 13 lines · Marek Vasut
Quoted 12 lines · Kees Cook

Commit 781a07da9bb9 ("Input: ads7846 - add dummy command register clearing cycle") added commands to struct ser_req::xfer without expanding it to hold them. Expand the array to the correct size.

../drivers/input/touchscreen/ads7846.c: In function 'ads7846_read12_ser':
../drivers/input/touchscreen/ads7846.c:416:18: error: array subscript 7 is above array bounds of 'struct spi_transfer[6]' [-Werror=array-bounds=]

   416 |         req->xfer[7].rx_buf = &req->scratch;
       |         ~~~~~~~~~^~~
../drivers/input/touchscreen/ads7846.c:334:33: note: while referencing 'xfer'
   334 |         struct spi_transfer     xfer[6];
       |                                 ^~~~
Quoted 3 lines
Quoted 2 lines
Fixes 781a07da9bb9 ("Input: ads7846 - add dummy command register clearing cycle")

I think Nathan already sent a fix too.

Oh excellent! I did a search in lore before sending it but must have failed to find it. Do you have a link to it?

-Kees

Signature · 1 line
Kees Cook
maintainer
#3 lore raw
Quoted 14 lines · Kees Cook
Quoted 13 lines · Marek Vasut
Quoted 12 lines · Kees Cook

Commit 781a07da9bb9 ("Input: ads7846 - add dummy command register clearing cycle") added commands to struct ser_req::xfer without expanding it to hold them. Expand the array to the correct size.

../drivers/input/touchscreen/ads7846.c: In function 'ads7846_read12_ser':
../drivers/input/touchscreen/ads7846.c:416:18: error: array subscript 7 is above array bounds of 'struct spi_transfer[6]' [-Werror=array-bounds=]

   416 |         req->xfer[7].rx_buf = &req->scratch;
       |         ~~~~~~~~~^~~
../drivers/input/touchscreen/ads7846.c:334:33: note: while referencing 'xfer'
   334 |         struct spi_transfer     xfer[6];
       |                                 ^~~~
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Fixes 781a07da9bb9 ("Input: ads7846 - add dummy command register clearing cycle")

I think Nathan already sent a fix too.

Oh excellent! I did a search in lore before sending it but must have failed to find it. Do you have a link to it?

I am pretty sure I applied the fix already, but I might have forgotten to push it out. My workstation is offline at the moment, when it comes back online I'll make sure the fix is there.

Thanks.

Signature · 1 line
Dmitry