[PATCH 11/11] ocfs2: One function call less in ocfs2_journal_shutdown() from input checks

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

 



From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 5 Jul 2015 14:54:33 +0200

The iput() function was called in one case by the ocfs2_journal_shutdown()
function during input parameter validation even if the passed
variable contained still a null pointer.

* Return directly if received values indicate that at the beginning.

* Delete the unnecessary jump label "done".

* Drop unnecessary initialisations for the variables "inode",
  "journal" and "num_running_trans" then.

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

diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 7bb50f4..f13e6fdb 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -951,22 +951,20 @@ static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb,
  */
 void ocfs2_journal_shutdown(struct ocfs2_super *osb)
 {
-	struct ocfs2_journal *journal = NULL;
+	struct ocfs2_journal *journal;
 	int status = 0;
-	struct inode *inode = NULL;
-	int num_running_trans = 0;
+	struct inode *inode;
+	int num_running_trans;
 
 	BUG_ON(!osb);
 
 	journal = osb->journal;
 	if (!journal)
-		goto done;
-
-	inode = journal->j_inode;
-
+		return;
 	if (journal->j_state != OCFS2_JOURNAL_LOADED)
-		goto done;
+		return;
 
+	inode = journal->j_inode;
 	/* need to inc inode use count - jbd2_journal_destroy will iput. */
 	if (!igrab(inode))
 		BUG();
@@ -1025,7 +1023,6 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)
 	journal->j_state = OCFS2_JOURNAL_FREE;
 
 //	up_write(&journal->j_trans_barrier);
-done:
 	iput(inode);
 }
 
-- 
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