[PATCH] tftp: allocate at least 4096 bytes for FIFO
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Sep 5 00:00:32 PDT 2022
On one board, boots from /mnt/tftp currently fail for me with:
ERROR: tftp: tftp: not enough room in kfifo (only 1376 out of 1432 written
This is overly annoying, because it doesn't abort the boot and thus an
incomplete image is started, that eventually crashes.
As this didn't happen with the previous hardcoded value of 4096, restore
working order by ensuring we have at least that many bytes in the kfifo.
Fixes: 480ed057aacb ("tftp: allocate buffers and fifo dynamically")
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
fs/tftp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/tftp.c b/fs/tftp.c
index 2bffae2bf36e..e1c1b0e7269f 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -546,7 +546,7 @@ static int tftp_allocate_transfer(struct file_priv *priv)
/* multiplication is safe; both operands were checked in tftp_parse_oack()
and are small integers */
- priv->fifo = kfifo_alloc(priv->blocksize * priv->windowsize);
+ priv->fifo = kfifo_alloc(max(priv->blocksize * priv->windowsize, 4096U));
if (!priv->fifo)
goto err;
--
2.30.2
More information about the barebox
mailing list