[PATCH] staging: axis-fifo: fix tx_fifo_depth underflow in write

From: LiuJunyuan

Date: Tue Oct 20 2026 - 23:40:21 EST


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@xxxxxx>
---
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