From nobody Fri Apr 17 10:46:19 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AFF6C4321E for ; Fri, 2 Dec 2022 12:45:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233559AbiLBMpl (ORCPT ); Fri, 2 Dec 2022 07:45:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232801AbiLBMpj (ORCPT ); Fri, 2 Dec 2022 07:45:39 -0500 Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 216F5DCBD9 for ; Fri, 2 Dec 2022 04:45:34 -0800 (PST) Received: from dev011.ch-qa.sw.ru ([172.29.1.16]) by relay.virtuozzo.com with esmtp (Exim 4.95) (envelope-from ) id 1p15Pp-005MRe-O6; Fri, 02 Dec 2022 13:45:17 +0100 From: Alexander Atanasov To: Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: kernel@openvz.org, Alexander Atanasov , linux-kernel@vger.kernel.org Subject: [PATCH] devtmpfs: move NULLing the thread pointer before unregistering fs Date: Fri, 2 Dec 2022 14:45:01 +0200 Message-Id: <20221202124502.217462-1-alexander.atanasov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In commit 31c779f293b3 ("devtmpfs: fix the dangling pointer of global devtmpfsd threa= d") a dangling pointer on an error condition was fixed. But the fix left the dangling pointer during unregister_filesystem and printk calls. Improve the fix to clear the pointer before unregistration to close the window where the dangling pointer can be potentially used. Make it clear the pointer at only one place in the function. Signed-off-by: Alexander Atanasov --- drivers/base/devtmpfs.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c index e4bffeabf344..773e66ef5642 100644 --- a/drivers/base/devtmpfs.c +++ b/drivers/base/devtmpfs.c @@ -472,17 +472,15 @@ int __init devtmpfs_init(void) } =20 thread =3D kthread_run(devtmpfsd, &err, "kdevtmpfs"); - if (!IS_ERR(thread)) { + if (!IS_ERR(thread)) wait_for_completion(&setup_done); - } else { + else err =3D PTR_ERR(thread); - thread =3D NULL; - } =20 if (err) { + thread =3D NULL; printk(KERN_ERR "devtmpfs: unable to create devtmpfs %i\n", err); unregister_filesystem(&dev_fs_type); - thread =3D NULL; return err; } =20 base-commit: b7b275e60bcd5f89771e865a8239325f86d9927d --=20 2.31.1