Message ID | 20220427172152.3505364-1-minchan@kernel.org |
---|---|
State | Accepted |
Commit | ad8d869343ae4a07a2038a4ca923f699308c8323 |
Headers | show |
Series | kernfs: fix NULL dereferencing in kernfs_remove | expand |
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index 61a8edc4ba8b..e205fde7163a 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c @@ -1406,7 +1406,12 @@ static void __kernfs_remove(struct kernfs_node *kn) */ void kernfs_remove(struct kernfs_node *kn) { - struct kernfs_root *root = kernfs_root(kn); + struct kernfs_root *root; + + if (!kn) + return; + + root = kernfs_root(kn); down_write(&root->kernfs_rwsem); __kernfs_remove(kn);