* [PATCH] axis-fifo: use size_t for write size calculations
@ 2026-07-31 3:43 Lucas Jeffrey
2026-07-31 11:10 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: Lucas Jeffrey @ 2026-07-31 3:43 UTC (permalink / raw)
To: gregkh
Cc: ovidiu.panait.oss, gustavopiazdasilva2102, error27, linux-staging,
linux-kernel, Lucas Jeffrey
The write length is provided as size_t, but words_to_write and the
return value storage used narrower types. Use size_t for the word count
and ssize_t for the return value to keep the types consistent with the
write interface.
This avoids relying on implicit size limits when handling write sizes.
Signed-off-by: Lucas Jeffrey <luquijeffrey@gmail.com>
---
drivers/staging/axis-fifo/axis-fifo.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c
index 3aa2aa870ea9..d2b30b7b6845 100644
--- a/drivers/staging/axis-fifo/axis-fifo.c
+++ b/drivers/staging/axis-fifo/axis-fifo.c
@@ -214,9 +214,9 @@ static ssize_t axis_fifo_write(struct file *f, const char __user *buf,
size_t len, loff_t *off)
{
struct axis_fifo *fifo = f->private_data;
- unsigned int words_to_write;
+ size_t words_to_write;
u32 *txbuf;
- int ret;
+ ssize_t ret;
words_to_write = len / sizeof(u32);
@@ -257,7 +257,7 @@ static ssize_t axis_fifo_write(struct file *f, const char __user *buf,
goto end_unlock;
}
- for (int i = 0; i < words_to_write; ++i)
+ for (size_t i = 0; i < words_to_write; ++i)
iowrite32(txbuf[i], fifo->base_addr + XLLF_TDFD_OFFSET);
iowrite32(len, fifo->base_addr + XLLF_TLR_OFFSET);
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] axis-fifo: use size_t for write size calculations
2026-07-31 3:43 [PATCH] axis-fifo: use size_t for write size calculations Lucas Jeffrey
@ 2026-07-31 11:10 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2026-07-31 11:10 UTC (permalink / raw)
To: Lucas Jeffrey
Cc: gregkh, ovidiu.panait.oss, gustavopiazdasilva2102, linux-staging,
linux-kernel
On Fri, Jul 31, 2026 at 12:43:07AM -0300, Lucas Jeffrey wrote:
> The write length is provided as size_t, but words_to_write and the
> return value storage used narrower types. Use size_t for the word count
> and ssize_t for the return value to keep the types consistent with the
> write interface.
>
> This avoids relying on implicit size limits when handling write sizes.
>
> Signed-off-by: Lucas Jeffrey <luquijeffrey@gmail.com>
> ---
This doesn't affect real life because len is capped in rw_verify_area().
The commit message needs to make it clear that this is just a clean up
and not a fix. If we pretended that the len value in read/write
functions was an range from 0-ULONG_MAX then we would have a ton of
integer overflow bugs etc.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-31 11:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-31 3:43 [PATCH] axis-fifo: use size_t for write size calculations Lucas Jeffrey
2026-07-31 11:10 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox