[PATCH 09/11] ocfs2: One function call less in ocfs2_trylock_journal() after error detection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 4 Jul 2015 22:34:43 +0200

The iput() function was called in one case by the
ocfs2_trylock_journal() function during error handling even
if the passed variable "inode" contained still a null pointer.

* Return directly if a call of the ocfs2_get_system_file_inode() function
  failed at the beginning.

* Rename a jump label according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
 fs/ocfs2/journal.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index c644997..c343e36 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -1749,21 +1749,18 @@ static int ocfs2_trylock_journal(struct ocfs2_super *osb,
 				 int slot_num)
 {
 	int status, flags;
-	struct inode *inode = NULL;
+	struct inode *inode;
 
 	inode = ocfs2_get_system_file_inode(osb, JOURNAL_SYSTEM_INODE,
 					    slot_num);
 	if (inode == NULL) {
 		mlog(ML_ERROR, "access error\n");
-		status = -EACCES;
-		goto bail;
+		return -EACCES;
 	}
 	if (is_bad_inode(inode)) {
 		mlog(ML_ERROR, "access error (bad inode)\n");
-		iput(inode);
-		inode = NULL;
 		status = -EACCES;
-		goto bail;
+		goto put_inode;
 	}
 	SET_INODE_JOURNAL(inode);
 
@@ -1772,11 +1769,11 @@ static int ocfs2_trylock_journal(struct ocfs2_super *osb,
 	if (status < 0) {
 		if (status != -EAGAIN)
 			mlog_errno(status);
-		goto bail;
+		goto put_inode;
 	}
 
 	ocfs2_inode_unlock(inode, 1);
-bail:
+put_inode:
 	iput(inode);
 	return status;
 }
-- 
2.4.5

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux