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>
This commit is contained in:
parent
a6aae4dd0f
commit
4994297606
|
@ -1740,16 +1740,20 @@ int ubifs_lpt_init(struct ubifs_info *c, int rd, int wr)
|
||||||
if (rd) {
|
if (rd) {
|
||||||
err = lpt_init_rd(c);
|
err = lpt_init_rd(c);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
goto out_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wr) {
|
if (wr) {
|
||||||
err = lpt_init_wr(c);
|
err = lpt_init_wr(c);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
goto out_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
out_err:
|
||||||
|
ubifs_lpt_free(c, 0);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue