All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: linux-fsdevel@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>,
	Joel Granados <j.granados@samsung.com>,
	Kees Cook <kees@kernel.org>, Luis Chamberlain <mcgrof@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] sysctl: Reduce dput(child) calls in proc_sys_fill_cache()
Date: Thu, 26 Sep 2024 10:20:34 +0200	[thread overview]
Message-ID: <7be4c6d7-4da1-43bb-b081-522a8339fd99@web.de> (raw)

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

A dput(child) call was immediately used after an error pointer check
for a d_splice_alias() call in this function implementation.
Thus call such a function instead directly before the check.

This issue was transformed by using the Coccinelle software.

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

diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index d11ebc055ce0..97547de58218 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -698,11 +698,11 @@ static bool proc_sys_fill_cache(struct file *file,
 			res = d_splice_alias(inode, child);
 			d_lookup_done(child);
 			if (unlikely(res)) {
-				if (IS_ERR(res)) {
-					dput(child);
-					return false;
-				}
 				dput(child);
+
+				if (IS_ERR(res))
+					return false;
+
 				child = res;
 			}
 		}
--
2.46.1


             reply	other threads:[~2024-09-26  8:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-26  8:20 Markus Elfring [this message]
2024-10-23 11:11 ` [PATCH] sysctl: Reduce dput(child) calls in proc_sys_fill_cache() Joel Granados
2024-10-23 12:10   ` Markus Elfring
2024-10-23 13:20     ` Joel Granados
2024-10-23 15:27       ` [PATCH v2] " Markus Elfring
2024-10-28  9:23         ` Joel Granados
2024-10-28 12:56           ` [v2] " Markus Elfring
2024-10-31 10:19         ` [PATCH v2] " Joel Granados

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=7be4c6d7-4da1-43bb-b081-522a8339fd99@web.de \
    --to=markus.elfring@web.de \
    --cc=j.granados@samsung.com \
    --cc=kees@kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.