* [PATCH] xfs: use kmalloc_array() instead of kmalloc() in xfs_da_grow_inode_int
@ 2026-07-14 9:17 Cihan Karadag
2026-07-14 15:42 ` Darrick J. Wong
0 siblings, 1 reply; 2+ messages in thread
From: Cihan Karadag @ 2026-07-14 9:17 UTC (permalink / raw)
To: Carlos Maiolino
Cc: Cihan Karadag, Darrick J . Wong, Shuah Khan, linux-xfs,
linux-kernel
Replace the open-coded
sizeof(*mapp) * count
multiplication with kmalloc_array(), based on kernel coding guidelines
against open-coded arithmetic in allocator arguments.
Signed-off-by: Cihan Karadag <cihan.cihan@gmail.com>
---
fs/xfs/libxfs/xfs_da_btree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index 9debb95d86fa0..99e4318ba75f2 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -2354,7 +2354,7 @@ xfs_da_grow_inode_int(
* If we didn't get it and the block might work if fragmented,
* try without the CONTIG flag. Loop until we get it all.
*/
- mapp = kmalloc(sizeof(*mapp) * count,
+ mapp = kmalloc_array(count, sizeof(*mapp),
GFP_KERNEL | __GFP_NOFAIL);
for (b = *bno, mapi = 0; b < *bno + count; ) {
c = (int)(*bno + count - b);
--
2.54.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] xfs: use kmalloc_array() instead of kmalloc() in xfs_da_grow_inode_int
2026-07-14 9:17 [PATCH] xfs: use kmalloc_array() instead of kmalloc() in xfs_da_grow_inode_int Cihan Karadag
@ 2026-07-14 15:42 ` Darrick J. Wong
0 siblings, 0 replies; 2+ messages in thread
From: Darrick J. Wong @ 2026-07-14 15:42 UTC (permalink / raw)
To: Cihan Karadag; +Cc: Carlos Maiolino, Shuah Khan, linux-xfs, linux-kernel
On Tue, Jul 14, 2026 at 03:17:24AM -0600, Cihan Karadag wrote:
> Replace the open-coded
>
> sizeof(*mapp) * count
>
> multiplication with kmalloc_array(), based on kernel coding guidelines
> against open-coded arithmetic in allocator arguments.
>
> Signed-off-by: Cihan Karadag <cihan.cihan@gmail.com>
> ---
> fs/xfs/libxfs/xfs_da_btree.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> index 9debb95d86fa0..99e4318ba75f2 100644
> --- a/fs/xfs/libxfs/xfs_da_btree.c
> +++ b/fs/xfs/libxfs/xfs_da_btree.c
> @@ -2354,7 +2354,7 @@ xfs_da_grow_inode_int(
> * If we didn't get it and the block might work if fragmented,
> * try without the CONTIG flag. Loop until we get it all.
> */
> - mapp = kmalloc(sizeof(*mapp) * count,
> + mapp = kmalloc_array(count, sizeof(*mapp),
> GFP_KERNEL | __GFP_NOFAIL);
kmalloc_objs?
--D
> for (b = *bno, mapi = 0; b < *bno + count; ) {
> c = (int)(*bno + count - b);
> --
> 2.54.0
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-14 15:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-14 9:17 [PATCH] xfs: use kmalloc_array() instead of kmalloc() in xfs_da_grow_inode_int Cihan Karadag
2026-07-14 15:42 ` Darrick J. Wong
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.