configfs: move the dereference below the NULL test
authorWei Yongjun <yongjun_wei@trendmicro.com.cn>
Fri, 22 Feb 2013 00:42:43 +0000 (16:42 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 22 Feb 2013 01:22:19 +0000 (17:22 -0800)
The dereference should be moved below the NULL test.

spatch with a semantic match is used to found this.
(http://coccinelle.lip6.fr/)

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/configfs/dir.c

index 712b10f64c709ff8a27d423aa7a5186f80aec04f..e9dcfa3c208c64bd4bce51f310c97b2981fd2a4a 100644 (file)
@@ -1037,10 +1037,11 @@ static int configfs_dump(struct configfs_dirent *sd, int level)
 static int configfs_depend_prep(struct dentry *origin,
                                struct config_item *target)
 {
-       struct configfs_dirent *child_sd, *sd = origin->d_fsdata;
+       struct configfs_dirent *child_sd, *sd;
        int ret = 0;
 
-       BUG_ON(!origin || !sd);
+       BUG_ON(!origin || !origin->d_fsdata);
+       sd = origin->d_fsdata;
 
        if (sd->s_element == target)  /* Boo-yah */
                goto out;