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 1/2] ubifs: Call iput(xino) only once in ubifs_purge_xattrs()
Date: Thu, 26 Sep 2024 11:49:26 +0200	[thread overview]
Message-ID: <c5bd9bb7-2636-4c48-9623-4c93ded3469c@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:05:29 +0200

An iput(xino) call was immediately used after a return value check
for a remove_xattr() call in this function implementation.
Thus call such a function only once instead directly before the check.

This issue was transformed by using the Coccinelle software.

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

diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
index f734588b224a..7757959e9f09 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -541,16 +541,14 @@ int ubifs_purge_xattrs(struct inode *host)

 		clear_nlink(xino);
 		err = remove_xattr(c, host, xino, &nm);
+		iput(xino);
 		if (err) {
 			kfree(pxent);
 			kfree(xent);
-			iput(xino);
 			ubifs_err(c, "cannot remove xattr, error %d", err);
 			goto out_err;
 		}

-		iput(xino);
-
 		kfree(pxent);
 		pxent = xent;
 		key_read(c, &xent->key, &key);
--
2.46.1


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

  reply	other threads:[~2024-09-26  9:53 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 ` Markus Elfring [this message]
2024-09-26 11:12   ` [PATCH 1/2] ubifs: Call iput(xino) only once in ubifs_purge_xattrs() Zhihao Cheng
2024-09-26  9:50 ` [PATCH 2/2] ubifs: Reduce kfree() calls " Markus Elfring
2024-09-26 11:13   ` 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=c5bd9bb7-2636-4c48-9623-4c93ded3469c@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