From: User <julianpoulainpro@gmail.com>
To: gregkh@linuxfoundation.org, linux-staging@lists.linux.dev
Cc: linux-kernel@vger.kernel.org, User <julianpoulainpro@gmail.com>
Subject: [PATCH] staging: axis-fifo: validate tx_fifo_depth in axis_fifo_parse_dt()
Date: Sat, 19 Sep 2026 12:05:11 +0200 [thread overview]
Message-ID: <20260919100511.16032-1-julianpoulainpro@gmail.com> (raw)
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
next reply other threads:[~2026-09-19 10:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 10:05 User [this message]
2026-09-19 10:26 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260919100511.16032-1-julianpoulainpro@gmail.com \
--to=julianpoulainpro@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®