Skip to contentSkip to conversation

fuse: Uninitialized variable in fuse_epoch_work()

PATCH Superseded Dan Carpenter 2 participants 5 messages Nov 21, 2025 – Nov 24, 2025

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fuse: Uninitialized variable in fuse_epoch_work()

The "fm" pointer is either valid or uninitialized so checking for NULL doesn't work. Check the "inode" pointer instead.

Fixes 64becd224ff9 ("fuse: new work queue to invalidate dentries from old epochs")
---
 fs/fuse/dir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fuse/dir.c +1 -1
index 761f4a14dc95..ec5042b47abb 100644
@@ -201,7 +201,7 @@ void fuse_epoch_work(struct work_struct *work)
 	inode = fuse_ilookup(fc, FUSE_ROOT_ID, &fm);
 	iput(inode);
 
-	if (fm) {
+	if (inode) {
 		/* Remove all possible active references to cached inodes */
 		shrink_dcache_sb(fm->sb);
 	} else
Signature · 1 line
2.51.0
#1 lore raw
Quoted 2 lines · Dan Carpenter

The "fm" pointer is either valid or uninitialized so checking for NULL doesn't work. Check the "inode" pointer instead.

Hmm? Why do you say 'fm' isn't initialised? That's what fuse_ilookup() is doing, isn't it?

Cheers,

Signature · 1 line
Luís
Quoted 22 lines
Fixes 64becd224ff9 ("fuse: new work queue to invalidate dentries from old epochs")
---
 fs/fuse/dir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fuse/dir.c +1 -1
index 761f4a14dc95..ec5042b47abb 100644
@@ -201,7 +201,7 @@ void fuse_epoch_work(struct work_struct *work)
 	inode = fuse_ilookup(fc, FUSE_ROOT_ID, &fm);
 	iput(inode);
 
-	if (fm) {
+	if (inode) {
 		/* Remove all possible active references to cached inodes */
 		shrink_dcache_sb(fm->sb);
 	} else
Signature · 1 line
2.51.0
#2 lore raw
Quoted 8 lines · Luis Henriques
Quoted 2 lines · Dan Carpenter

The "fm" pointer is either valid or uninitialized so checking for NULL doesn't work. Check the "inode" pointer instead.

Hmm? Why do you say 'fm' isn't initialised? That's what fuse_ilookup() is doing, isn't it?

I just checked again on linux-next. fuse_ilookup() only initializes *fm on the success path. It's either uninitialized or valid.

regards,
dan carpenter

Reviewed-by
#3 lore raw
Quoted 6 lines · Dan Carpenter
Quoted 5 lines · Luis Henriques
Quoted 2 lines · Dan Carpenter

The "fm" pointer is either valid or uninitialized so checking for NULL doesn't work. Check the "inode" pointer instead.

Quoted 6 lines
Quoted 3 lines

Hmm? Why do you say 'fm' isn't initialised? That's what fuse_ilookup() is doing, isn't it?

I just checked again on linux-next. fuse_ilookup() only initializes *fm on the success path. It's either uninitialized or valid.

Yikes! You're absolutely right, I'm sorry for replying without checking.

Feel free to add my

Although I guess you're patch could also move the iput():

fs/fuse/dir.c +2 -3
index 67e3340a443c..f2bac7b3a125 100644
@@ -199,9 +199,8 @@ void fuse_epoch_work(struct work_struct *work)
 	down_read(&fc->killsb);
 
 	inode = fuse_ilookup(fc, FUSE_ROOT_ID, &fm);
-	iput(inode);
-
-	if (fm) {
+	if (inode) {
+		iput(inode);
 		/* Remove all possible active references to cached inodes */
 		shrink_dcache_sb(fm->sb);
 	} else

And thanks for your fix, Dan!

Cheers,

Signature · 1 line
Luís
#4 lore raw
Quoted 15 lines · Luis Henriques
Quoted 6 lines · Dan Carpenter
Quoted 5 lines · Luis Henriques
Quoted 2 lines · Dan Carpenter

The "fm" pointer is either valid or uninitialized so checking for NULL doesn't work. Check the "inode" pointer instead.

Quoted 6 lines
Quoted 3 lines

Hmm? Why do you say 'fm' isn't initialised? That's what fuse_ilookup() is doing, isn't it?

I just checked again on linux-next. fuse_ilookup() only initializes *fm on the success path. It's either uninitialized or valid.

Quoted 8 lines

Yikes! You're absolutely right, I'm sorry for replying without checking.

Feel free to add my

Although I guess you're patch could also move the iput():

Yeah. Good point. It's cleaner that way. I've sent a v2.

regards,
dan carpenter