[PATCH] fs: avoid uninitialized var warning

Sascha Hauer s.hauer at pengutronix.de
Mon Nov 7 02:28:00 PST 2022

With gcc-12.2.1-clang-15.0.2-glibc-2.36-binutils-2.39-kernel-6.0.5-sanitized
we get a warning about path.dentry being used uninitialized:

fs/fs.c:1978:43: warning: 'path.dentry' may be used uninitialized -Wmaybe-uninitialized]

I can't see how this can really happen. gcc seems to think that this
sequence used in lookup_fast() can result in returning 0:

	if (IS_ERR(dentry))
		return PTR_ERR(dentry);

This shouldn't happen. Silence the warning by initializing 'path'.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
 fs/fs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/fs.c b/fs/fs.c
index 8f21420494..b5a0912405 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1956,7 +1956,7 @@ static inline int step_into(struct nameidata *nd, struct path *path,
 static int walk_component(struct nameidata *nd, int flags)
-	struct path path;
+	struct path path = {};
 	int err;

More information about the barebox mailing list