diff options
author | Boris BREZILLON <boris.brezillon@free-electrons.com> | 2015-07-30 12:18:03 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-02-17 12:34:35 -0800 |
commit | 6188cfb97ed5b33080b4052695ec0b8aa53e648d (patch) | |
tree | a2b411bc27647c4d72552ea31d9437820f610ef4 /drivers | |
parent | 2060578571caa130c8483a10fbc4292da6082009 (diff) | |
download | lwn-6188cfb97ed5b33080b4052695ec0b8aa53e648d.tar.gz lwn-6188cfb97ed5b33080b4052695ec0b8aa53e648d.zip |
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/mtdpart.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 3c7d6d7623c1..e638993ac626 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c @@ -635,8 +635,10 @@ int add_mtd_partitions(struct mtd_info *master, for (i = 0; i < nbparts; i++) { slave = allocate_partition(master, parts + i, i, cur_offset); - if (IS_ERR(slave)) + if (IS_ERR(slave)) { + del_mtd_partitions(master); return PTR_ERR(slave); + } mutex_lock(&mtd_partitions_mutex); list_add(&slave->list, &mtd_partitions); |