mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH driver-core-next] kernfs: remove unnecessary NULL check in __kernfs_remove()
@ 2014-01-11 23:23 Tejun Heo
  0 siblings, 0 replies; only message in thread
From: Tejun Heo @ 2014-01-11 23:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Dan Carpenter

895a068a524e ("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>
---
 fs/kernfs/dir.c |    3 ---
 1 file changed, 3 deletions(-)

--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -920,9 +920,6 @@ static void __kernfs_remove(struct kernf
 
 	lockdep_assert_held(&kernfs_mutex);
 
-	if (!kn)
-		return;
-
 	pr_debug("kernfs %s: removing\n", kn->name);
 
 	__kernfs_deactivate(kn);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-01-11 23:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-11 23:23 [PATCH driver-core-next] kernfs: remove unnecessary NULL check in __kernfs_remove() Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®