From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>,
Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] tftp: allocate at least 4096 bytes for FIFO
Date: Mon, 5 Sep 2022 09:00:32 +0200 [thread overview]
Message-ID: <20220905070032.536912-1-a.fatoum@pengutronix.de> (raw)
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@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
next reply other threads:[~2022-09-05 7:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-05 7:00 Ahmad Fatoum [this message]
2022-09-05 9:03 ` Enrico Scholz
2022-09-05 12:07 ` Ahmad Fatoum
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=20220905070032.536912-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=enrico.scholz@sigma-chemnitz.de \
/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