summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-05-18 14:32:36 +0300
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-05-23 13:04:02 +0300
commitc19428ec620d8b1243c45fc1728a7abadb37ddb7 (patch)
tree8a6b1dee35f251e4bf46c7fa478c52e6a6ad28c7 /fs
parent3802570c292d453cc577bb75ffde1abcda68076f (diff)
UBIFS: make ubifs_lpt_init clean-up in case of failure
Most functions in UBIFS follow the following designn pattern: if the function allocates multiple resources, and failss at some point, it frees what it has allocated and returns an error. So the caller can rely on the fact that the callee has cleaned up everything after own failure. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Acked-by: Sidney Amani <seed95@gmail.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ubifs/lpt.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c
index 2054e8171fd4..b4280c44949c 100644
--- a/fs/ubifs/lpt.c
+++ b/fs/ubifs/lpt.c
@@ -1740,16 +1740,20 @@ int ubifs_lpt_init(struct ubifs_info *c, int rd, int wr)
if (rd) {
err = lpt_init_rd(c);
if (err)
- return err;
+ goto out_err;
}
if (wr) {
err = lpt_init_wr(c);
if (err)
- return err;
+ goto out_err;
}
return 0;
+
+out_err:
+ ubifs_lpt_free(c, 0);
+ return err;
}
/**