mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] staging: axis-fifo: validate tx_fifo_depth in axis_fifo_parse_dt()
@ 2026-09-19 10:05 User
  2026-09-19 10:26 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: User @ 2026-09-19 10:05 UTC (permalink / raw)
  To: gregkh, linux-staging; +Cc: linux-kernel, User

tx_fifo_depth is read from the device tree as an unsigned int and
later used in axis_fifo_write() as:

    words_to_write > (fifo->tx_fifo_depth - 4)

If tx_fifo_depth is <= 4, the unsigned subtraction wraps around to
a very large value, making the bounds check ineffective. This can
cause the calling process to block indefinitely waiting for a FIFO
vacancy that will never be reached.

Add a validation check in axis_fifo_parse_dt() to reject invalid
values at probe time with a clear error message.

Compile-tested with:
  make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- \
       drivers/staging/axis-fifo/axis-fifo.o

Signed-off-by: User <julianpoulainpro@gmail.com>
---
 drivers/staging/axis-fifo/axis-fifo.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c
index 3d358f919..bc8a380ae 100644
--- a/drivers/staging/axis-fifo/axis-fifo.c
+++ b/drivers/staging/axis-fifo/axis-fifo.c
@@ -413,6 +413,13 @@ static int axis_fifo_parse_dt(struct axis_fifo *fifo)
 	if (ret)
 		return ret;
 
+	if (fifo->tx_fifo_depth <= 4) {
+		dev_err(fifo->dt_device,
+			"invalid xlnx,tx-fifo-depth (%u), must be > 4\n",
+			fifo->tx_fifo_depth);
+		return -EINVAL;
+	}
+
 	ret = of_property_read_u32(node, "xlnx,use-rx-data",
 				   &fifo->has_rx_fifo);
 	if (ret)
-- 
2.53.0


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

* Re: [PATCH] staging: axis-fifo: validate tx_fifo_depth in axis_fifo_parse_dt()
  2026-09-19 10:05 [PATCH] staging: axis-fifo: validate tx_fifo_depth in axis_fifo_parse_dt() User
@ 2026-09-19 10:26 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2026-09-19 10:26 UTC (permalink / raw)
  To: User; +Cc: linux-staging, linux-kernel

On Sat, Sep 19, 2026 at 12:05:11PM +0200, User wrote:
> tx_fifo_depth is read from the device tree as an unsigned int and
> later used in axis_fifo_write() as:
> 
>     words_to_write > (fifo->tx_fifo_depth - 4)
> 
> If tx_fifo_depth is <= 4, the unsigned subtraction wraps around to
> a very large value, making the bounds check ineffective. This can
> cause the calling process to block indefinitely waiting for a FIFO
> vacancy that will never be reached.
> 
> Add a validation check in axis_fifo_parse_dt() to reject invalid
> values at probe time with a clear error message.

Please tell your LLM script that device tree values are "trusted".

> 
> Compile-tested with:
>   make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- \
>        drivers/staging/axis-fifo/axis-fifo.o
> 
> Signed-off-by: User <julianpoulainpro@gmail.com>

Not a valid name, sorry.

And again, don't use LLMs on drivers/staging/ without reading the email
archives first.

thanks,

greg k-h

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

end of thread, other threads:[~2026-09-19 10:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-19 10:05 [PATCH] staging: axis-fifo: validate tx_fifo_depth in axis_fifo_parse_dt() User
2026-09-19 10:26 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®