* [PATCH] Input: ads7846 - Increase xfer array size in 'struct ser_req'
@ 2024-11-11 15:09 Nathan Chancellor
2024-11-11 16:18 ` Marek Vasut
2024-11-15 2:04 ` Dmitry Torokhov
0 siblings, 2 replies; 3+ messages in thread
From: Nathan Chancellor @ 2024-11-11 15:09 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Marek Vasut, linux-input, llvm, patches, Nathan Chancellor
Clang warns (or errors with CONFIG_WERROR=y, trimmed for brevity):
drivers/input/touchscreen/ads7846.c:412:2: error: array index 6 is past the end of the array (that has type 'struct spi_transfer[6]') [-Werror,-Warray-bounds]
412 | req->xfer[6].tx_buf = &req->scratch;
| ^ ~
...
drivers/input/touchscreen/ads7846.c:416:2: error: array index 7 is past the end of the array (that has type 'struct spi_transfer[6]') [-Werror,-Warray-bounds]
416 | req->xfer[7].rx_buf = &req->scratch;
| ^ ~
drivers/input/touchscreen/ads7846.c:334:2: note: array 'xfer' declared here
334 | struct spi_transfer xfer[6];
| ^
Increase the size of xfer in 'struct ser_req' to ensure that there is
enough space for all necessary members and there are no out of bounds
accesses, clearing up the warning.
Fixes: 781a07da9bb9 ("Input: ads7846 - add dummy command register clearing cycle")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
drivers/input/touchscreen/ads7846.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index f7bc0a3e56d86932823b6bc0dcd6bcd8e1b9b5c2..7b3711a3597c86f18c45d040f73bef884ec3c4aa 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -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.
---
base-commit: bed0f75909b21c0cd0285da76fdfcc61a9745b0c
change-id: 20241111-input-ads7846-increase-xfer-array-size-2603a15ad062
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] Input: ads7846 - Increase xfer array size in 'struct ser_req'
2024-11-11 15:09 [PATCH] Input: ads7846 - Increase xfer array size in 'struct ser_req' Nathan Chancellor
@ 2024-11-11 16:18 ` Marek Vasut
2024-11-15 2:04 ` Dmitry Torokhov
1 sibling, 0 replies; 3+ messages in thread
From: Marek Vasut @ 2024-11-11 16:18 UTC (permalink / raw)
To: Nathan Chancellor, Dmitry Torokhov; +Cc: linux-input, llvm, patches
On 11/11/24 4:09 PM, Nathan Chancellor wrote:
> Clang warns (or errors with CONFIG_WERROR=y, trimmed for brevity):
>
> drivers/input/touchscreen/ads7846.c:412:2: error: array index 6 is past the end of the array (that has type 'struct spi_transfer[6]') [-Werror,-Warray-bounds]
> 412 | req->xfer[6].tx_buf = &req->scratch;
> | ^ ~
> ...
> drivers/input/touchscreen/ads7846.c:416:2: error: array index 7 is past the end of the array (that has type 'struct spi_transfer[6]') [-Werror,-Warray-bounds]
> 416 | req->xfer[7].rx_buf = &req->scratch;
> | ^ ~
> drivers/input/touchscreen/ads7846.c:334:2: note: array 'xfer' declared here
> 334 | struct spi_transfer xfer[6];
> | ^
>
> Increase the size of xfer in 'struct ser_req' to ensure that there is
> enough space for all necessary members and there are no out of bounds
> accesses, clearing up the warning.
>
> Fixes: 781a07da9bb9 ("Input: ads7846 - add dummy command register clearing cycle")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> drivers/input/touchscreen/ads7846.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
> index f7bc0a3e56d86932823b6bc0dcd6bcd8e1b9b5c2..7b3711a3597c86f18c45d040f73bef884ec3c4aa 100644
> --- a/drivers/input/touchscreen/ads7846.c
> +++ b/drivers/input/touchscreen/ads7846.c
> @@ -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];
Sigh ...
Reviewed-by: Marek Vasut <marex@denx.de>
Thank you
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] Input: ads7846 - Increase xfer array size in 'struct ser_req'
2024-11-11 15:09 [PATCH] Input: ads7846 - Increase xfer array size in 'struct ser_req' Nathan Chancellor
2024-11-11 16:18 ` Marek Vasut
@ 2024-11-15 2:04 ` Dmitry Torokhov
1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2024-11-15 2:04 UTC (permalink / raw)
To: Nathan Chancellor; +Cc: Marek Vasut, linux-input, llvm, patches
On Mon, Nov 11, 2024 at 08:09:55AM -0700, Nathan Chancellor wrote:
> Clang warns (or errors with CONFIG_WERROR=y, trimmed for brevity):
>
> drivers/input/touchscreen/ads7846.c:412:2: error: array index 6 is past the end of the array (that has type 'struct spi_transfer[6]') [-Werror,-Warray-bounds]
> 412 | req->xfer[6].tx_buf = &req->scratch;
> | ^ ~
> ...
> drivers/input/touchscreen/ads7846.c:416:2: error: array index 7 is past the end of the array (that has type 'struct spi_transfer[6]') [-Werror,-Warray-bounds]
> 416 | req->xfer[7].rx_buf = &req->scratch;
> | ^ ~
> drivers/input/touchscreen/ads7846.c:334:2: note: array 'xfer' declared here
> 334 | struct spi_transfer xfer[6];
> | ^
>
> Increase the size of xfer in 'struct ser_req' to ensure that there is
> enough space for all necessary members and there are no out of bounds
> accesses, clearing up the warning.
>
> Fixes: 781a07da9bb9 ("Input: ads7846 - add dummy command register clearing cycle")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Applied, thank you.
--
Dmitry
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-15 2:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-11 15:09 [PATCH] Input: ads7846 - Increase xfer array size in 'struct ser_req' Nathan Chancellor
2024-11-11 16:18 ` Marek Vasut
2024-11-15 2:04 ` Dmitry Torokhov
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).