mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] staging: axis-fifo: fix tx_fifo_depth underflow in write
@ 2026-10-21  3:29 LiuJunyuan
  2026-10-21  6:00 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: LiuJunyuan @ 2026-10-21  3:29 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, linux-kernel, LiuJunyuan

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


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

* Re: [PATCH] staging: axis-fifo: fix tx_fifo_depth underflow in write
  2026-10-21  3:29 [PATCH] staging: axis-fifo: fix tx_fifo_depth underflow in write LiuJunyuan
@ 2026-10-21  6:00 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2026-10-21  6:00 UTC (permalink / raw)
  To: LiuJunyuan; +Cc: gregkh, linux-staging, linux-kernel

On Wed, Oct 21, 2026 at 11:29:08AM +0800, LiuJunyuan wrote:
> 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>

AI loves to make this change, but actually we trust device tree
information.

regards,
dan carpenter


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

end of thread, other threads:[~2026-10-21  6:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-21  3:29 [PATCH] staging: axis-fifo: fix tx_fifo_depth underflow in write LiuJunyuan
2026-10-21  6:00 ` Dan Carpenter

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®