[PATCH v3 27/39] ubifs: check inode with NULL before using it

Dongsheng Yang yangds.fnst at cn.fujitsu.com
Tue Sep 15 02:02:22 PDT 2015


There is a checking of inode with NULL after ubifs_inode(inode),
that's not readable, why we need to check a pointer with NULL
after we having used it?

Although inode=NULL will not hurt ubifs_inode(), checking inode
following new_inode() directly before using it seems more reasonable.

Signed-off-by: Dongsheng Yang <yangds.fnst at cn.fujitsu.com>
---
 fs/ubifs/dir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index a822148..4db0ceb 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -92,10 +92,10 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir,
 	struct ubifs_inode *ui;
 
 	inode = new_inode(c->vfs_sb);
-	ui = ubifs_inode(inode);
 	if (!inode)
 		return ERR_PTR(-ENOMEM);
 
+	ui = ubifs_inode(inode);
 	/*
 	 * Set 'S_NOCMTIME' to prevent VFS form updating [mc]time of inodes and
 	 * marking them dirty in file write path (see 'file_update_time()').
-- 
1.8.4.2




More information about the linux-mtd mailing list