diff mbox series

[3/7] ubifs: do not call ubifs_inode() on unchecked pointer

Message ID 20210330104351.21328-4-s.hauer@pengutronix.de
State Under Review
Delegated to: Richard Weinberger
Headers show
Series Add quota support to UBIFS | expand

Commit Message

Sascha Hauer March 30, 2021, 10:43 a.m. UTC
new_inode() may return NULL, so only derefence the return inode when
it's non NULL. This is merely a cleanup as calling ubifs_inode() on a
NULL pointer doesn't do any harm, only using the result would.
Nevertheless using inode only after it has been checked for validity
looks much cleaner.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/ubifs/dir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index d9d8d7794eff..ba4944c87a2c 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -82,10 +82,10 @@  struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir,
 	bool encrypted = false;
 
 	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()').