Skip to content

Commit 88533f9

Browse files
htejungregkh
authored andcommitted
kernfs: remove unnecessary NULL check in __kernfs_remove()
895a068 ("kernfs: make kernfs_get_active() block if the node is deactivated but not removed") added "struct kernfs_root *root = kernfs_root(kn);" at the head of the function; however, the parameter @kn is checked for later implying that the function may be called with NULL. This means that we may end up invoking kernfs_root() with NULL which will oops. None of the existing users invokes removal with NULL @kn, so this bug doesn't actually trigger. We can relocate kernfs_root() invocation after NULL check; however, allowing NULL param tends to cause more confusion than actually helping anything. As there's no existing user, let's remove the spurious NULL check. This bug was detected by smatch. Signed-off-by: Tejun Heo <tj@kernel.org> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2a41e60 commit 88533f9

1 file changed

Lines changed: 0 additions & 3 deletions

File tree

‎fs/kernfs/dir.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -920,9 +920,6 @@ static void __kernfs_remove(struct kernfs_node *kn)
920920

921921
lockdep_assert_held(&kernfs_mutex);
922922

923-
if (!kn)
924-
return;
925-
926923
pr_debug("kernfs %s: removing\n", kn->name);
927924

928925
__kernfs_deactivate(kn);

0 commit comments

Comments
 (0)