public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: linux-mtd@lists.infradead.org,
	Richard Weinberger <richard@nod.at>,
	Zhihao Cheng <chengzhihao1@huawei.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 2/2] ubifs: Reduce kfree() calls in ubifs_purge_xattrs()
Date: Thu, 26 Sep 2024 11:50:40 +0200	[thread overview]
Message-ID: <fc35a4b0-9a41-4f14-9558-99fc0b7e2ad8@web.de> (raw)
In-Reply-To: <ff787fb9-a9fc-4798-8460-3ec310e6cd9f@web.de>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 26 Sep 2024 11:28:48 +0200

Move a pair of kfree() calls behind the label “out_err”
so that two statements can be better reused at the end of
this function implementation.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/ubifs/xattr.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
index 7757959e9f09..a514dc4dc535 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -532,8 +532,6 @@ int ubifs_purge_xattrs(struct inode *host)
 			ubifs_err(c, "dead directory entry '%s', error %d",
 				  xent->name, err);
 			ubifs_ro_mode(c, err);
-			kfree(pxent);
-			kfree(xent);
 			goto out_err;
 		}

@@ -543,8 +541,6 @@ int ubifs_purge_xattrs(struct inode *host)
 		err = remove_xattr(c, host, xino, &nm);
 		iput(xino);
 		if (err) {
-			kfree(pxent);
-			kfree(xent);
 			ubifs_err(c, "cannot remove xattr, error %d", err);
 			goto out_err;
 		}
@@ -564,6 +560,8 @@ int ubifs_purge_xattrs(struct inode *host)
 	return 0;

 out_err:
+	kfree(pxent);
+	kfree(xent);
 	up_write(&ubifs_inode(host)->xattr_sem);
 	return err;
 }
--
2.46.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  parent reply	other threads:[~2024-09-26  9:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-26  9:48 [PATCH 0/2] ubifs: Adjustments for ubifs_purge_xattrs() Markus Elfring
2024-09-26  9:49 ` [PATCH 1/2] ubifs: Call iput(xino) only once in ubifs_purge_xattrs() Markus Elfring
2024-09-26 11:12   ` Zhihao Cheng
2024-09-26  9:50 ` Markus Elfring [this message]
2024-09-26 11:13   ` [PATCH 2/2] ubifs: Reduce kfree() calls " Zhihao Cheng

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=fc35a4b0-9a41-4f14-9558-99fc0b7e2ad8@web.de \
    --to=markus.elfring@web.de \
    --cc=chengzhihao1@huawei.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    /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