Skip to content

Commit 9c738da

Browse files
elfringJoelgranados
authored andcommitted
sysctl: Reduce dput(child) calls in proc_sys_fill_cache()
Replace two dput(child) calls with one that occurs immediately before the IS_ERR evaluation. This transformation can be performed because dput() gets called regardless of the value returned by IS_ERR(res). This issue was transformed by using a script for the semantic patch language like the following. <SmPL> @extended_adjustment@ expression e, f != { mutex_unlock }, x, y; @@ +f(e); if (...) { <+... when != \( e = x \| y(..., &e, ...) \) - f(e); ...+> } -f(e); </SmPL> Signed-off-by: Markus Elfring <[email protected]> Reviewed-by: Joel Granados <[email protected]> Signed-off-by: Joel Granados <[email protected]>
1 parent a883f2e commit 9c738da

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fs/proc/proc_sysctl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -704,11 +704,11 @@ static bool proc_sys_fill_cache(struct file *file,
704704
res = d_splice_alias(inode, child);
705705
d_lookup_done(child);
706706
if (unlikely(res)) {
707-
if (IS_ERR(res)) {
708-
dput(child);
709-
return false;
710-
}
711707
dput(child);
708+
709+
if (IS_ERR(res))
710+
return false;
711+
712712
child = res;
713713
}
714714
}

0 commit comments

Comments
 (0)