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 inff9fb72bc0
("debugfs: return error values, not NULL") we caused some subsystems to easily crash. Fixes:ff9fb72bc0
("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>
This commit is contained in:
parent
ff9fb72bc0
commit
37ea7b630a
|
@ -254,8 +254,8 @@ MODULE_ALIAS_FS("debugfs");
|
||||||
* @parent: a pointer to the parent dentry of the file.
|
* @parent: a pointer to the parent dentry of the file.
|
||||||
*
|
*
|
||||||
* This function will return a pointer to a dentry if it succeeds. If the file
|
* This function will return a pointer to a dentry if it succeeds. If the file
|
||||||
* doesn't exist or an error occurs, %ERR_PTR(-ERROR) will be returned. The
|
* doesn't exist or an error occurs, %NULL will be returned. The returned
|
||||||
* returned dentry must be passed to dput() when it is no longer needed.
|
* dentry must be passed to dput() when it is no longer needed.
|
||||||
*
|
*
|
||||||
* If debugfs is not enabled in the kernel, the value -%ENODEV will be
|
* If debugfs is not enabled in the kernel, the value -%ENODEV will be
|
||||||
* returned.
|
* returned.
|
||||||
|
@ -265,17 +265,17 @@ struct dentry *debugfs_lookup(const char *name, struct dentry *parent)
|
||||||
struct dentry *dentry;
|
struct dentry *dentry;
|
||||||
|
|
||||||
if (IS_ERR(parent))
|
if (IS_ERR(parent))
|
||||||
return parent;
|
return NULL;
|
||||||
|
|
||||||
if (!parent)
|
if (!parent)
|
||||||
parent = debugfs_mount->mnt_root;
|
parent = debugfs_mount->mnt_root;
|
||||||
|
|
||||||
dentry = lookup_one_len_unlocked(name, parent, strlen(name));
|
dentry = lookup_one_len_unlocked(name, parent, strlen(name));
|
||||||
if (IS_ERR(dentry))
|
if (IS_ERR(dentry))
|
||||||
return dentry;
|
return NULL;
|
||||||
if (!d_really_is_positive(dentry)) {
|
if (!d_really_is_positive(dentry)) {
|
||||||
dput(dentry);
|
dput(dentry);
|
||||||
return ERR_PTR(-EINVAL);
|
return NULL;
|
||||||
}
|
}
|
||||||
return dentry;
|
return dentry;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue