From: LiuJunyuan <2058432396@qq.com>
To: gregkh@linuxfoundation.org
Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
LiuJunyuan <2058432396@qq.com>
Subject: [PATCH] staging: axis-fifo: fix tx_fifo_depth underflow in write
Date: Wed, 21 Oct 2026 11:29:08 +0800 [thread overview]
Message-ID: <tencent_8D0F8B2180750F84AF2D147AC203FEA9F406@qq.com> (raw)
Check fifo->tx_fifo_depth before subtracting four words to avoid an
unsigned underflow when the device tree provides an invalid depth.
Signed-off-by: LiuJunyuan <2058432396@qq.com>
---
drivers/staging/axis-fifo/axis-fifo.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c
index 7bb35e11d1dd..178514a71734 100644
--- a/drivers/staging/axis-fifo/axis-fifo.c
+++ b/drivers/staging/axis-fifo/axis-fifo.c
@@ -228,7 +228,8 @@ static ssize_t axis_fifo_write(struct file *f, const char __user *buf,
* raised, which requires a reset of the TX circuit to recover.
*/
if (!words_to_write || (len % sizeof(u32)) ||
- (words_to_write > (fifo->tx_fifo_depth - 4)))
+ (fifo->tx_fifo_depth <= 4) ||
+ (words_to_write > fifo->tx_fifo_depth - 4))
return -EINVAL;
if (f->f_flags & O_NONBLOCK) {
--
2.43.0
next reply other threads:[~2026-10-21 3:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 3:29 LiuJunyuan [this message]
2026-10-21 6:00 ` Dan Carpenter
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=tencent_8D0F8B2180750F84AF2D147AC203FEA9F406@qq.com \
--to=2058432396@qq.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®