Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 641c7925 authored by Richard Weinberger's avatar Richard Weinberger Committed by Brian Norris
Browse files

mtd: nandsim: Fix kasprintf() usage



kasprintf() used in get_partition_name() does a dynamic
memory allocation and can fail. We have to handle that case.

Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
parent bc349da0
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -743,6 +743,11 @@ static int init_nandsim(struct mtd_info *mtd)
			goto error;
		}
		ns->partitions[i].name   = get_partition_name(i);
		if (!ns->partitions[i].name) {
			NS_ERR("unable to allocate memory.\n");
			ret = -ENOMEM;
			goto error;
		}
		ns->partitions[i].offset = next_offset;
		ns->partitions[i].size   = part_sz;
		next_offset += ns->partitions[i].size;
@@ -756,6 +761,11 @@ static int init_nandsim(struct mtd_info *mtd)
			goto error;
		}
		ns->partitions[i].name   = get_partition_name(i);
		if (!ns->partitions[i].name) {
			NS_ERR("unable to allocate memory.\n");
			ret = -ENOMEM;
			goto error;
		}
		ns->partitions[i].offset = next_offset;
		ns->partitions[i].size   = remains;
		ns->nbparts += 1;