From: "Darrick J. Wong" <djwong@kernel.org>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: linux-xfs@vger.kernel.org, Carlos Maiolino <cem@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
Dave Chinner <dchinner@redhat.com>
Subject: Re: [PATCH] xfs: Improve error handling in xfs_mru_cache_create()
Date: Tue, 10 Jun 2025 07:59:02 -0700 [thread overview]
Message-ID: <20250610145902.GN6156@frogsfrogsfrogs> (raw)
In-Reply-To: <b182b740-e68d-4466-a10d-bcb8afb2453a@web.de>
On Tue, Jun 10, 2025 at 03:00:27PM +0200, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 10 Jun 2025 14:50:07 +0200
>
> Simplify error handling in this function implementation.
>
> * Delete unnecessary pointer checks and variable assignments.
>
> * Omit a redundant function call.
>
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Looks ok,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> fs/xfs/xfs_mru_cache.c | 15 ++++-----------
> 1 file changed, 4 insertions(+), 11 deletions(-)
>
> diff --git a/fs/xfs/xfs_mru_cache.c b/fs/xfs/xfs_mru_cache.c
> index 08443ceec329..2ed679a52e41 100644
> --- a/fs/xfs/xfs_mru_cache.c
> +++ b/fs/xfs/xfs_mru_cache.c
> @@ -320,7 +320,7 @@ xfs_mru_cache_create(
> xfs_mru_cache_free_func_t free_func)
> {
> struct xfs_mru_cache *mru = NULL;
> - int err = 0, grp;
> + int grp;
> unsigned int grp_time;
>
> if (mrup)
> @@ -341,8 +341,8 @@ xfs_mru_cache_create(
> mru->lists = kzalloc(mru->grp_count * sizeof(*mru->lists),
> GFP_KERNEL | __GFP_NOFAIL);
> if (!mru->lists) {
> - err = -ENOMEM;
> - goto exit;
> + kfree(mru);
> + return -ENOMEM;
> }
>
> for (grp = 0; grp < mru->grp_count; grp++)
> @@ -361,14 +361,7 @@ xfs_mru_cache_create(
> mru->free_func = free_func;
> mru->data = data;
> *mrup = mru;
> -
> -exit:
> - if (err && mru && mru->lists)
> - kfree(mru->lists);
> - if (err && mru)
> - kfree(mru);
> -
> - return err;
> + return 0;
> }
>
> /*
> --
> 2.49.0
>
>
next prev parent reply other threads:[~2025-06-10 14:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-10 13:00 [PATCH] xfs: Improve error handling in xfs_mru_cache_create() Markus Elfring
2025-06-10 14:59 ` Darrick J. Wong [this message]
2025-06-16 12:31 ` 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=20250610145902.GN6156@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=Markus.Elfring@web.de \
--cc=cem@kernel.org \
--cc=dchinner@redhat.com \
--cc=hch@lst.de \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.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