[PATCH] staging: axis-fifo: validate tx_fifo_depth in axis_fifo_parse_dt()
From: User
Date: Sat Sep 19 2026 - 06:10:52 EST
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@xxxxxxxxx>
---
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