From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 D688E3A6B8A; Thu, 11 Jun 2026 20:01:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781208085; cv=none; b=CJgLWjPFErSXg3q5Djeya3wyVztNJntvYn7PTC0JRgBDS8w4TsSqDaapwJNAQALLbgUB3XpD39wvPLY8ZP69ir7zgQfro2wl/bqqIKhoDaibcpwu4PfkGmjfNKDbxCVF1kQDXTv18mIGRN1Ihhuub2xVEdsp67t83dQB7JIxzC0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781208085; c=relaxed/simple; bh=GSV+awQnsJrlDXWrlE1rxpTRBAf1BESk3mbVPVLP+44=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aiusWpEZoLpQfRBmnFGtCBQV12TB0Dshw635XNxodZy/rUhTns6q+tlNIlMunRPN58aNPHG65mRALEePAewX8KmZ5b2R9kv36V0RBa5PeKoykia150C5Hz2O5tPqvUI/+6x38Pp8pt6X4sjcnljMS8uh72YG9Wo0869tvvj7MDU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OOkT6M3P; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OOkT6M3P" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0613A1F00A3F; Thu, 11 Jun 2026 20:01:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781208083; bh=uOTV08GArOROL2+n6RTSN8k7YFnXkm2fcSjaekYgxzQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=OOkT6M3Pp20rNVyVnmCe6kogzwOnwWavJBWaql1v6Bi2re6jvqIzlrkxWxGeV6Un4 XwdGDju6emM2bHah6KLxaxxeTHZ1T0gJL0WMEiMNagP8gR267uNs2G32oPn+CD5NDg apHnzn4SJwqf/ad2criXpTcGCI9BlDFyEsR0dVVs5Fw3pKic7Nai0CkL9yugvFRT5Y AxIRObBMtE8dXvOFkNUdCjncLSeHgfSuccK2CQwBWs2LQyuo1IqtubyXQOOKbmBo3+ yv04sXG53LHdupb1h7pqu5DyDKcoeFxLY2oxUNPKdgNox5slsuKsqBpD2/xECEOLXw N02HT+u/Hiq6A== From: Jeff Layton Date: Thu, 11 Jun 2026 16:01:00 -0400 Subject: [PATCH v2 17/21] nfsd: move nfsd_debugfs_init() after nfsd4_init_slabs() in init_nfsd() Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260611-nfsd-testing-v2-17-5b90e276f2d9@kernel.org> References: <20260611-nfsd-testing-v2-0-5b90e276f2d9@kernel.org> In-Reply-To: <20260611-nfsd-testing-v2-0-5b90e276f2d9@kernel.org> To: Chuck Lever , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: Chris Mason , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1939; i=jlayton@kernel.org; h=from:subject:message-id; bh=GSV+awQnsJrlDXWrlE1rxpTRBAf1BESk3mbVPVLP+44=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBqKxQA9rdCBl5sJ0EM2VLGkQTeYMC+8ZF5eZrFR PI+NQAaMQCJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCaisUAAAKCRAADmhBGVaC Fc0YD/4iY2L5PxtQmTJsxcbygSJ5EcOwpptva3oDARVt/hETZtXG/QKaC+UDCKvr/WfuQns+psn jaWkHu4Im3XQ2G4zjcRrfBT1U8tAYcNt7dFjtuAY5URtQHuoHp8dPlm3T24oyR3q/Hmk2FBj5eH PrNDeRW8XOq0tCDaYQU5A4cnzwmu0Ej1DTEIJVrZ5deTmZzlWglkQ9WCQJrizhnPjosG9yDn1a2 gBsY5DPfKtwa7LD98r99q9ksYoML+txEPJqgLSs8UnY1uKKbAzdVb+SrkMpqV6ghJ3S3DPZjJ3I SWnNmu/YfIYtZqdZwujcQ9oD6o6otUOit7qXDTgzmCYYiVZUvKBRpdVw9cI3gsDr+kPr8yJv6v7 jjgjJsybo7v9yD3a6oXvTcc0jmhO3FmESzSbBHLvNbFE+kqu1v588yFQOmIr0S4IsPXPK//VtOH k4zg9J9lwSUasbmUOvknYCPnW/W+H5OpTut5oEDYr8pp4Xr53tc8vmdf1sbYiq+YapBw2WuOFz6 PyrAq8jkRIhIRGVTlfOtudNQ4xIyN/61Dz+dFfmp44AngWHzAyAhXZM77U9tijRvWLjnGcTSyVo wyD8/1OVOvyO6UIo0qewF+ZYXLdNsd1UddE3BtdzhL3vMPyFpU/1lRyBfkqxclFPGSgOMYgi58E oRxGKYandgRH+JA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 nfsd_debugfs_init() runs before nfsd4_init_slabs() in init_nfsd(). If the slab allocation fails, the bare "return retval" bypasses nfsd_debugfs_exit(), leaving orphan debugfs files with stale fops pointers into the freed module text. Move nfsd_debugfs_init() to after the slab init succeeds, so the early return has no debugfs state to clean up. Since debugfs is now the more recently initialized of the two, also update the unwind paths to match reverse-initialization (LIFO) order: run nfsd_debugfs_exit() before nfsd4_free_slabs() in both the init_nfsd() error path and exit_nfsd(). The nfsd debugfs files only reference module-global state and have no dependency on the slab caches, so that reordering is a cleanup with no functional change. Fixes: 9fe5ea760e64 ("NFSD: Add /sys/kernel/debug/nfsd") Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Jeff Layton --- fs/nfsd/nfsctl.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index f3b3154b16c5..720b481bb7ad 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -2557,11 +2557,12 @@ static int __init init_nfsd(void) { int retval; - nfsd_debugfs_init(); - retval = nfsd4_init_slabs(); if (retval) return retval; + + nfsd_debugfs_init(); + retval = nfsd4_init_pnfs(); if (retval) goto out_free_slabs; @@ -2606,8 +2607,8 @@ static int __init init_nfsd(void) out_free_pnfs: nfsd4_exit_pnfs(); out_free_slabs: - nfsd4_free_slabs(); nfsd_debugfs_exit(); + nfsd4_free_slabs(); return retval; } @@ -2622,9 +2623,9 @@ static void __exit exit_nfsd(void) unregister_pernet_subsys(&nfsd_net_ops); nfsd_drc_slab_free(); nfsd_lockd_shutdown(); - nfsd4_free_slabs(); nfsd4_exit_pnfs(); nfsd_debugfs_exit(); + nfsd4_free_slabs(); } MODULE_AUTHOR("Olaf Kirch "); -- 2.54.0