* [PATCH master] fs: guard against unset dentry in get_fsdevice_by_dentry
@ 2026-04-15 10:39 Ahmad Fatoum
2026-04-15 12:08 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2026-04-15 10:39 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
dentry exists embedded within struct path and may not be initialized at
all places we call get_fsdevice_by_dentry().
Allow handling this gracefully by having the function return NULL
instead of dereferencing potential NULL pointers.
This issue has been detected in combination with the
"fs: fix relative path resolution when CWD is on a TFTP mount" patch
sitting in next, where the MLO runs into the NULL pointer dereference.
It has not been observed in other configurations.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
fs/fs.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/fs/fs.c b/fs/fs.c
index 6a73a5baa26e..c28192cb8260 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -2099,9 +2099,12 @@ static void putname(struct filename *name)
static struct fs_device *get_fsdevice_by_dentry(struct dentry *dentry)
{
- struct super_block *sb;
+ struct super_block *sb = NULL;
- sb = dentry->d_sb;
+ if (dentry)
+ sb = dentry->d_sb;
+ if (!sb)
+ return NULL;
return container_of(sb, struct fs_device, sb);
}
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH master] fs: guard against unset dentry in get_fsdevice_by_dentry
2026-04-15 10:39 [PATCH master] fs: guard against unset dentry in get_fsdevice_by_dentry Ahmad Fatoum
@ 2026-04-15 12:08 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2026-04-15 12:08 UTC (permalink / raw)
To: barebox, Ahmad Fatoum
On Wed, 15 Apr 2026 12:39:54 +0200, Ahmad Fatoum wrote:
> dentry exists embedded within struct path and may not be initialized at
> all places we call get_fsdevice_by_dentry().
>
> Allow handling this gracefully by having the function return NULL
> instead of dereferencing potential NULL pointers.
>
> This issue has been detected in combination with the
> "fs: fix relative path resolution when CWD is on a TFTP mount" patch
> sitting in next, where the MLO runs into the NULL pointer dereference.
> It has not been observed in other configurations.
>
> [...]
Applied, thanks!
[1/1] fs: guard against unset dentry in get_fsdevice_by_dentry
https://git.pengutronix.de/cgit/barebox/commit/?id=ff129a9c4049 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-15 12:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-15 10:39 [PATCH master] fs: guard against unset dentry in get_fsdevice_by_dentry Ahmad Fatoum
2026-04-15 12:08 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox