Linux-EROFS Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Yue Hu <zbestahu@gmail.com>
To: Noboru Asai <asai@sijam.com>
Cc: linux-erofs@lists.ozlabs.org, huyue2@coolpad.com, zhangwen@coolpad.com
Subject: Re: [PATCH] erofs: avoid useless memory allocation
Date: Fri, 3 Mar 2023 17:45:48 +0800	[thread overview]
Message-ID: <20230303174548.00000b0b.zbestahu@gmail.com> (raw)
In-Reply-To: <20230303075218.675733-1-asai@sijam.com>

On Fri,  3 Mar 2023 16:52:18 +0900
Noboru Asai <asai@sijam.com> wrote:

> The variable 'vi->xattr_shared_count' could be ZERO.
> 
> Signed-off-by: Noboru Asai <asai@sijam.com>
> ---
>  fs/erofs/xattr.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c
> index 60729b1220b6..5164813a693b 100644
> --- a/fs/erofs/xattr.c
> +++ b/fs/erofs/xattr.c
> @@ -80,6 +80,8 @@ static int init_inode_xattrs(struct inode *inode)
>  
>  	ih = (struct erofs_xattr_ibody_header *)(it.kaddr + it.ofs);
>  	vi->xattr_shared_count = ih->h_shared_count;
> +	if (!vi->xattr_shared_count)
> +		goto out_unlock;

Questions: ret = 0? no need to erofs_put_metabuf?

I think we can keep current since kmalloc_array() will check whether the
size(->xattr_shared_count) is zero size or not. rt?

>  	vi->xattr_shared_xattrs = kmalloc_array(vi->xattr_shared_count,
>  						sizeof(uint), GFP_KERNEL);
>  	if (!vi->xattr_shared_xattrs) {


  parent reply	other threads:[~2023-03-03  9:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-03  7:52 [PATCH] erofs: avoid useless memory allocation Noboru Asai
2023-03-03  7:59 ` Gao Xiang
2023-03-03  9:45 ` Yue Hu [this message]
2023-03-03 10:06   ` Gao Xiang
2023-03-03 10:14   ` 浅井登

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=20230303174548.00000b0b.zbestahu@gmail.com \
    --to=zbestahu@gmail.com \
    --cc=asai@sijam.com \
    --cc=huyue2@coolpad.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=zhangwen@coolpad.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