public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Viacheslav Dubeyko <vdubeyko@redhat.com>
To: Rosen Penev <rosenp@gmail.com>, linux-fsdevel@vger.kernel.org
Cc: Viacheslav Dubeyko <slava@dubeyko.com>,
	John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>,
	Yangtao Li <frank.li@vivo.com>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] hfs/hfxplus: use kzalloc_flex()
Date: Mon, 27 Apr 2026 11:40:19 -0700	[thread overview]
Message-ID: <f901feb6317d93a7cd55f6ec155340161b36f41e.camel@redhat.com> (raw)
In-Reply-To: <20260425014441.441252-1-rosenp@gmail.com>

On Fri, 2026-04-24 at 18:44 -0700, Rosen Penev wrote:
> Instead of doing the math manually, use kzalloc_flex() which does it in
> a cleaner way.
> 
> Also clarifies which is the flexible array member.
> 
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>  fs/hfs/bnode.c     | 6 ++----
>  fs/hfsplus/bnode.c | 6 ++----
>  2 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c
> index 13d58c51fc46..b0165de7640d 100644
> --- a/fs/hfs/bnode.c
> +++ b/fs/hfs/bnode.c
> @@ -344,7 +344,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
>  	struct hfs_bnode *node, *node2;
>  	struct address_space *mapping;
>  	struct page *page;
> -	int size, block, i, hash;
> +	int block, i, hash;
>  	loff_t off;
>  
>  	if (cnid >= tree->node_count) {
> @@ -352,9 +352,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
>  		return NULL;
>  	}
>  
> -	size = sizeof(struct hfs_bnode) + tree->pages_per_bnode *
> -		sizeof(struct page *);
> -	node = kzalloc(size, GFP_KERNEL);
> +	node = kzalloc_flex(*node, page, tree->pages_per_bnode, GFP_KERNEL);
>  	if (!node)
>  		return NULL;
>  	node->tree = tree;
> diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c
> index f8b5a8ae58ff..a717fa008ddd 100644
> --- a/fs/hfsplus/bnode.c
> +++ b/fs/hfsplus/bnode.c
> @@ -455,7 +455,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
>  	struct hfs_bnode *node, *node2;
>  	struct address_space *mapping;
>  	struct page *page;
> -	int size, block, i, hash;
> +	int block, i, hash;
>  	loff_t off;
>  
>  	if (cnid >= tree->node_count) {
> @@ -464,9 +464,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
>  		return NULL;
>  	}
>  
> -	size = sizeof(struct hfs_bnode) + tree->pages_per_bnode *
> -		sizeof(struct page *);
> -	node = kzalloc(size, GFP_KERNEL);
> +	node = kzalloc_flex(*node, page, tree->pages_per_bnode);
>  	if (!node)
>  		return NULL;
>  	node->tree = tree;

Makes sense.

Reviewed-by: Viacheslav Dubeyko <slava@dubeyko.com>

Thanks,
Slava.


      reply	other threads:[~2026-04-27 18:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-25  1:44 [PATCH] hfs/hfxplus: use kzalloc_flex() Rosen Penev
2026-04-27 18:40 ` Viacheslav Dubeyko [this message]

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=f901feb6317d93a7cd55f6ec155340161b36f41e.camel@redhat.com \
    --to=vdubeyko@redhat.com \
    --cc=frank.li@vivo.com \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rosenp@gmail.com \
    --cc=slava@dubeyko.com \
    /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