diff options
| author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-01-30 06:37:35 -0500 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-01-30 06:39:49 -0500 |
| commit | 37ea7b630ae5cdea4e8ff381d9d23abfef5939e6 (patch) | |
| tree | fd3836565f8255135394477d1fcc9d4fb5771286 | |
| parent | ff9fb72bc07705c00795ca48631f7fffe24d2c6b (diff) | |
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 ff9fb72bc077
("debugfs: return error values, not NULL") we caused some subsystems to
easily crash.
Fixes: ff9fb72bc077 ("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>
| -rw-r--r-- | fs/debugfs/inode.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index b16f8035b1af..29c68c5d44d5 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c | |||
| @@ -254,8 +254,8 @@ MODULE_ALIAS_FS("debugfs"); | |||
| 254 | * @parent: a pointer to the parent dentry of the file. | 254 | * @parent: a pointer to the parent dentry of the file. |
| 255 | * | 255 | * |
| 256 | * This function will return a pointer to a dentry if it succeeds. If the file | 256 | * 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 | 257 | * doesn't exist or an error occurs, %NULL will be returned. The returned |
| 258 | * returned dentry must be passed to dput() when it is no longer needed. | 258 | * dentry must be passed to dput() when it is no longer needed. |
| 259 | * | 259 | * |
| 260 | * If debugfs is not enabled in the kernel, the value -%ENODEV will be | 260 | * If debugfs is not enabled in the kernel, the value -%ENODEV will be |
| 261 | * returned. | 261 | * returned. |
| @@ -265,17 +265,17 @@ struct dentry *debugfs_lookup(const char *name, struct dentry *parent) | |||
| 265 | struct dentry *dentry; | 265 | struct dentry *dentry; |
| 266 | 266 | ||
| 267 | if (IS_ERR(parent)) | 267 | if (IS_ERR(parent)) |
| 268 | return parent; | 268 | return NULL; |
| 269 | 269 | ||
| 270 | if (!parent) | 270 | if (!parent) |
| 271 | parent = debugfs_mount->mnt_root; | 271 | parent = debugfs_mount->mnt_root; |
| 272 | 272 | ||
| 273 | dentry = lookup_one_len_unlocked(name, parent, strlen(name)); | 273 | dentry = lookup_one_len_unlocked(name, parent, strlen(name)); |
| 274 | if (IS_ERR(dentry)) | 274 | if (IS_ERR(dentry)) |
| 275 | return dentry; | 275 | return NULL; |
| 276 | if (!d_really_is_positive(dentry)) { | 276 | if (!d_really_is_positive(dentry)) { |
| 277 | dput(dentry); | 277 | dput(dentry); |
| 278 | return ERR_PTR(-EINVAL); | 278 | return NULL; |
| 279 | } | 279 | } |
| 280 | return dentry; | 280 | return dentry; |
| 281 | } | 281 | } |
