aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs/lpt.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-05-18 07:32:36 -0400
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-05-20 13:19:01 -0400
commit499429760650018216eb8d0b35067cf2c5c4520b (patch)
treeb5f717005065ae0e28fd6d3f586a12c18de6daad /fs/ubifs/lpt.c
parenta6aae4dd0ffad299a33d122f8a339b399bee5381 (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/ubifs/lpt.c')
-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)
1740 if (rd) { 1740 if (rd) {
1741 err = lpt_init_rd(c); 1741 err = lpt_init_rd(c);
1742 if (err) 1742 if (err)
1743 return err; 1743 goto out_err;
1744 } 1744 }
1745 1745
1746 if (wr) { 1746 if (wr) {
1747 err = lpt_init_wr(c); 1747 err = lpt_init_wr(c);
1748 if (err) 1748 if (err)
1749 return err; 1749 goto out_err;
1750 } 1750 }
1751 1751
1752 return 0; 1752 return 0;
1753
1754out_err:
1755 ubifs_lpt_free(c, 0);
1756 return err;
1753} 1757}
1754 1758
1755/** 1759/**