From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dongsheng Yang Subject: [PATCH v3 27/39] ubifs: check inode with NULL before using it Date: Tue, 15 Sep 2015 17:02:22 +0800 Message-ID: <1442307754-13233-28-git-send-email-yangds.fnst@cn.fujitsu.com> References: <1442307754-13233-1-git-send-email-yangds.fnst@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org, Dongsheng Yang , linux-mtd@lists.infradead.org To: , , , Return-path: In-Reply-To: <1442307754-13233-1-git-send-email-yangds.fnst@cn.fujitsu.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+gldm-linux-mtd-36=gmane.org@lists.infradead.org List-Id: linux-fsdevel.vger.kernel.org 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 --- 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 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/