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

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

mtd: cs553x_nand: Fix kasprintf() usage



kasprintf() 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 905cce7f
Loading
Loading
Loading
Loading
+9 −3
Original line number Original line Diff line number Diff line
@@ -237,17 +237,23 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)
	/* Enable the following for a flash based bad block table */
	/* Enable the following for a flash based bad block table */
	this->bbt_options = NAND_BBT_USE_FLASH;
	this->bbt_options = NAND_BBT_USE_FLASH;


	new_mtd->name = kasprintf(GFP_KERNEL, "cs553x_nand_cs%d", cs);
	if (!new_mtd->name) {
		err = -ENOMEM;
		goto out_ior;
	}

	/* Scan to find existence of the device */
	/* Scan to find existence of the device */
	if (nand_scan(new_mtd, 1)) {
	if (nand_scan(new_mtd, 1)) {
		err = -ENXIO;
		err = -ENXIO;
		goto out_ior;
		goto out_free;
	}
	}


	new_mtd->name = kasprintf(GFP_KERNEL, "cs553x_nand_cs%d", cs);

	cs553x_mtd[cs] = new_mtd;
	cs553x_mtd[cs] = new_mtd;
	goto out;
	goto out;


out_free:
	kfree(new_mtd->name);
out_ior:
out_ior:
	iounmap(this->IO_ADDR_R);
	iounmap(this->IO_ADDR_R);
out_mtd:
out_mtd: