Linux filesystem development
 help / color / mirror / Atom feed
* [PATCH] sysctl: Reduce dput(child) calls in proc_sys_fill_cache()
@ 2024-09-26  8:20 Markus Elfring
  2024-10-23 11:11 ` Joel Granados
  0 siblings, 1 reply; 8+ messages in thread
From: Markus Elfring @ 2024-09-26  8:20 UTC (permalink / raw)
  To: linux-fsdevel, Al Viro, Joel Granados, Kees Cook,
	Luis Chamberlain
  Cc: LKML, kernel-janitors

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-10-31 10:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-26  8:20 [PATCH] sysctl: Reduce dput(child) calls in proc_sys_fill_cache() Markus Elfring
2024-10-23 11:11 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox