]> git.baikalelectronics.ru Git - kernel.git/commit
mtd: ubi: fixup error correction in do_sync_erase()
authorSebastian Siewior <bigeasy@linutronix.de>
Thu, 26 Nov 2015 20:23:48 +0000 (21:23 +0100)
committerRichard Weinberger <richard@nod.at>
Wed, 16 Dec 2015 21:52:46 +0000 (22:52 +0100)
commit449a6c145cc67feb2cbb8988edc19d5f4b8ee9e4
treecc247bb7803e3576995306bf143c76a95b34c040
parentcba95cd6bd06d06ebb7497de7e62e016a4dfd5ac
mtd: ubi: fixup error correction in do_sync_erase()

Since fastmap we gained do_sync_erase(). This function can return an error
and its error handling isn't obvious. First the memory allocation for
struct ubi_work can fail and as such struct ubi_wl_entry is leaked.
However if the memory allocation succeeds then the tail function takes
care of the struct ubi_wl_entry. A free here could result in a double
free.
To make the error handling simpler, I split the tail function into one
piece which does the work and another which frees the struct ubi_work
which is passed as argument. As result do_sync_erase() can keep the
struct on stack and we get rid of one error source.

Cc: <stable@vger.kernel.org>
Fixes: 86614b57b ("UBI: Add fastmap support to the WL sub-system")
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Richard Weinberger <richard@nod.at>
drivers/mtd/ubi/wl.c