mtd: mtdpart: fix add_mtd_partitions error path
authorBoris BREZILLON <boris.brezillon@free-electrons.com>
Thu, 30 Jul 2015 10:18:03 +0000 (12:18 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 19 Feb 2016 22:22:38 +0000 (14:22 -0800)
commit98b3bd61b250e6ebe77f475d7dd0660eec20b183
treefd1af3acd9f047664b55970cfbc5127c9b9d27af
parent2acba4b8b307985e93a2d86e619f8a16d39a247b
mtd: mtdpart: fix add_mtd_partitions error path

commit e5bae86797141e4a95e42d825f737cb36d7b8c37 upstream.

If we fail to allocate a partition structure in the middle of the partition
creation process, the already allocated partitions are never removed, which
means they are still present in the partition list and their resources are
never freed.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mtd/mtdpart.c