From: Ruoyu Wang <ruoyuw560@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Tejun Heo <tj@kernel.org>,
driver-core@lists.linux.dev, linux-kernel@vger.kernel.org,
Ruoyu Wang <ruoyuw560@gmail.com>
Subject: [PATCH] kernfs: use nofail allocation for global locks
Date: Mon, 8 Jun 2026 14:36:55 +0800 [thread overview]
Message-ID: <20260608063655.69-1-ruoyuw560@gmail.com> (raw)
kernfs_lock_init() allocates the global kernfs lock storage during init
and then calls kernfs_mutex_init(), which initializes mutexes through the
allocated pointer. A WARN_ON() does not stop execution, so allocation
failure would still dereference NULL.
The lock storage is required for kernfs to operate. Use a nofail
GFP_KERNEL allocation so the init path does not continue without the
required object.
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
fs/kernfs/mount.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c
index 6e3217b6e4811..6cf8e71e5bd08 100644
--- a/fs/kernfs/mount.c
+++ b/fs/kernfs/mount.c
@@ -451,8 +451,8 @@ static void __init kernfs_mutex_init(void)
static void __init kernfs_lock_init(void)
{
- kernfs_locks = kmalloc_obj(struct kernfs_global_locks);
- WARN_ON(!kernfs_locks);
+ kernfs_locks = kmalloc_obj(struct kernfs_global_locks,
+ GFP_KERNEL | __GFP_NOFAIL);
kernfs_mutex_init();
}
--
2.51.0
next reply other threads:[~2026-06-08 6:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 6:36 Ruoyu Wang [this message]
2026-06-08 12:25 ` [PATCH] kernfs: use nofail allocation for global locks Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260608063655.69-1-ruoyuw560@gmail.com \
--to=ruoyuw560@gmail.com \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox