From: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Date: Fri, 25 Mar 2011 16:33:57 +0000 (+0200)
Subject: UBIFS: do not read flash unnecessarily
X-Git-Tag: firefly_0821_release~10186^2~246
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b7236edfb8caffe3d9348999e13c972666e96b44;p=firefly-linux-kernel-4.4.55.git

UBIFS: do not read flash unnecessarily

commit 8b229c76765816796eec7ccd428f03bd8de8b525 upstream.

This fix makes the 'dbg_check_old_index()' function return
immediately if debugging is disabled, instead of executing
incorrect 'goto out' which causes UBIFS to:

1. Allocate memory
2. Read the flash

On every commit. OK, we do not commit that often, but it is
still silly to do unneeded I/O anyway.

Credits to coverity for spotting this silly issue.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---

diff --git a/fs/ubifs/commit.c b/fs/ubifs/commit.c
index 4775af401167..0d948f1955f1 100644
--- a/fs/ubifs/commit.c
+++ b/fs/ubifs/commit.c
@@ -518,7 +518,7 @@ int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot)
 	size_t sz;
 
 	if (!(ubifs_chk_flags & UBIFS_CHK_OLD_IDX))
-		goto out;
+		return 0;
 
 	INIT_LIST_HEAD(&list);