Skip to content

Commit 37ea7b6

Browse files
committed
debugfs: debugfs_lookup() should return NULL if not found
Lots of callers of debugfs_lookup() were just checking NULL to see if the file/directory was found or not. By changing this in ff9fb72 ("debugfs: return error values, not NULL") we caused some subsystems to easily crash. Fixes: ff9fb72 ("debugfs: return error values, not NULL") Reported-by: syzbot+b382ba6a802a3d242790@syzkaller.appspotmail.com Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: Omar Sandoval <osandov@fb.com> Cc: Jens Axboe <axboe@fb.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ff9fb72 commit 37ea7b6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

fs/debugfs/inode.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ MODULE_ALIAS_FS("debugfs");
254254
* @parent: a pointer to the parent dentry of the file.
255255
*
256256
* This function will return a pointer to a dentry if it succeeds. If the file
257-
* doesn't exist or an error occurs, %ERR_PTR(-ERROR) will be returned. The
258-
* returned dentry must be passed to dput() when it is no longer needed.
257+
* doesn't exist or an error occurs, %NULL will be returned. The returned
258+
* dentry must be passed to dput() when it is no longer needed.
259259
*
260260
* If debugfs is not enabled in the kernel, the value -%ENODEV will be
261261
* returned.
@@ -265,17 +265,17 @@ struct dentry *debugfs_lookup(const char *name, struct dentry *parent)
265265
struct dentry *dentry;
266266

267267
if (IS_ERR(parent))
268-
return parent;
268+
return NULL;
269269

270270
if (!parent)
271271
parent = debugfs_mount->mnt_root;
272272

273273
dentry = lookup_one_len_unlocked(name, parent, strlen(name));
274274
if (IS_ERR(dentry))
275-
return dentry;
275+
return NULL;
276276
if (!d_really_is_positive(dentry)) {
277277
dput(dentry);
278-
return ERR_PTR(-EINVAL);
278+
return NULL;
279279
}
280280
return dentry;
281281
}

0 commit comments

Comments
 (0)