From nobody Fri Nov 29 00:36:04 2024 Received: from mout.web.de (mout.web.de [212.227.17.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D7821A704B; Thu, 26 Sep 2024 08:20:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727338857; cv=none; b=nJdHB4Y103F+7XUf2EpiOGnpxNeZ1s0gXYQzoKsnCchg2q1hibW3CJFgxOPTo1/hvrNqv3c+5yginmfs4cTzaDe2M6jDOdAFyjRVm8LMJV6OPXyzJINHPUZyjCrGbIWILcj+2F+VGKK2E4A40BKa30FxQvsBGW7Q4a3kZ2rhaUU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727338857; c=relaxed/simple; bh=DDb8C4BtA74QmAAeFYR18zjm0Ie12PG4cmEwax1hWiU=; h=Message-ID:Date:MIME-Version:To:Cc:From:Subject:Content-Type; b=jPwo8MrNcXTePa//P3azonKN2EPgSwnUt4gV+tnO63QkBETRTo8D5/OP91OmaaJHjXU0N9oL20oRqrt/J45gr8faCS9MI1BKNmw6BNTqenum3BCXxvL53v4IRTkYSVogEjRs5CrfpzvSU4ML3KQbt+K2ESwX0nN6Vww7v94OvQg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de; spf=pass smtp.mailfrom=web.de; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b=qMNIH1KY; arc=none smtp.client-ip=212.227.17.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=web.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b="qMNIH1KY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1727338835; x=1727943635; i=markus.elfring@web.de; bh=sB6yRJmW44vEhF2xRcb8ZnnullLqQ80g/LRUvvWZUBI=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:To:Cc:From: Subject:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=qMNIH1KYHG4V1vMq2T5N5iZJZ5T9lVw3VZiGEFENegvVz2QjRlad1CbDtqDsP4Uj rcAZ0SOUnPPvv8/K20XlA+GfR4gelgcPsvwqUTy06Iwl9yqrPI+LiNmCq1Aaq8HVB +XWNMOIzah7rFcLkEu8bdBE38b5DeDS44ixHmPGYDekbw41gfof7yZnutyMoPKSr6 u0IcKspa10DAtNP6xoVqYzOJjcJsKstAcNiHIf7IEOKMxC8sEk4TL5KICNZbngLPa yDFJpA37wqS31XwgIhr2OuJEhMGw6H35aYJZlQu6T+Lc/hl+NxfjcytF44ZkX6eHq /UfUlxGqo0cK9+PSQQ== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.84.95]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MjBRn-1sEt8g3Lt7-00hh4G; Thu, 26 Sep 2024 10:20:35 +0200 Message-ID: <7be4c6d7-4da1-43bb-b081-522a8339fd99@web.de> Date: Thu, 26 Sep 2024 10:20:34 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: linux-fsdevel@vger.kernel.org, Al Viro , Joel Granados , Kees Cook , Luis Chamberlain Content-Language: en-GB Cc: LKML , kernel-janitors@vger.kernel.org From: Markus Elfring Subject: [PATCH] sysctl: Reduce dput(child) calls in proc_sys_fill_cache() Content-Transfer-Encoding: quoted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JFjtyYZg9VDN857dgf95nwDzMy7BBR1zm9l Hr06K9n8pwuIJfpHwURNChbQ== Content-Type: text/plain; charset="utf-8" From: Markus Elfring 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 --- 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 =3D 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 =3D res; } } -- 2.46.1