The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Carlos Maiolino <cem@kernel.org>
To: Cihan Karadag <cihan.cihan@gmail.com>
Cc: "Darrick J . Wong" <djwong@kernel.org>,
	Shuah Khan <shuah@kernel.org>,
	 linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] xfs: use kmalloc_objs() instead of kmalloc() in xfs_da_grow_inode_int
Date: Mon, 20 Jul 2026 10:55:59 +0200	[thread overview]
Message-ID: <al3imFx2EbfalN3u@nidhogg.toxiclabs.cc> (raw)
In-Reply-To: <20260716214827.21188-1-cihan.cihan@gmail.com>

On Thu, Jul 16, 2026 at 03:48:12PM -0600, Cihan Karadag wrote:
> Convert open-coded kmalloc() multiplication to the modern kmalloc_objs()
> interface to improve type safety and prevent potential integer
> overflows.
> 
> No functional changes are intended.
> 
> Signed-off-by: Cihan Karadag <cihan.cihan@gmail.com>

Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>

> ---
> Changes since v1:
> - Use kmalloc_objs() instead of kmalloc_array(), per Darrick's suggestion.
> 
>  fs/xfs/libxfs/xfs_da_btree.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> index 9debb95d86fa0..f190c088591bc 100644
> --- a/fs/xfs/libxfs/xfs_da_btree.c
> +++ b/fs/xfs/libxfs/xfs_da_btree.c
> @@ -2354,8 +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,
> -				GFP_KERNEL | __GFP_NOFAIL);
> +		mapp = kmalloc_objs(*mapp, count, GFP_KERNEL | __GFP_NOFAIL);
>  		for (b = *bno, mapi = 0; b < *bno + count; ) {
>  			c = (int)(*bno + count - b);
>  			nmap = min(XFS_BMAP_MAX_NMAP, c);
> -- 
> 2.54.0
> 

  parent reply	other threads:[~2026-07-20  8:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-16 21:48 [PATCH v2] xfs: use kmalloc_objs() instead of kmalloc() in xfs_da_grow_inode_int Cihan Karadag
2026-07-17 15:16 ` Darrick J. Wong
2026-07-20  8:55 ` Carlos Maiolino [this message]
2026-07-21 10:44 ` Carlos Maiolino

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=al3imFx2EbfalN3u@nidhogg.toxiclabs.cc \
    --to=cem@kernel.org \
    --cc=cihan.cihan@gmail.com \
    --cc=djwong@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=shuah@kernel.org \
    /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