aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2015-06-01 17:10:51 -0400
committerBrian Norris <computersforpeace@gmail.com>2015-06-16 21:58:47 -0400
commitbc349da0a6b3c6cf795b6a51e3f448d9d16a1686 (patch)
tree4d2d1c24a9171267545f139053be9d42ae8489ee
parent905cce7f4309f3ec19c1ed67edd68b7e67e88f3e (diff)
mtd: cs553x_nand: Fix kasprintf() usage
kasprintf() does a dynamic memory allocation and can fail. We have to handle that case. Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-rw-r--r--drivers/mtd/nand/cs553x_nand.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/mtd/nand/cs553x_nand.c b/drivers/mtd/nand/cs553x_nand.c
index 88109d375ae7..aec6045058c7 100644
--- a/drivers/mtd/nand/cs553x_nand.c
+++ b/drivers/mtd/nand/cs553x_nand.c
@@ -237,17 +237,23 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)
237 /* Enable the following for a flash based bad block table */ 237 /* Enable the following for a flash based bad block table */
238 this->bbt_options = NAND_BBT_USE_FLASH; 238 this->bbt_options = NAND_BBT_USE_FLASH;
239 239
240 new_mtd->name = kasprintf(GFP_KERNEL, "cs553x_nand_cs%d", cs);
241 if (!new_mtd->name) {
242 err = -ENOMEM;
243 goto out_ior;
244 }
245
240 /* Scan to find existence of the device */ 246 /* Scan to find existence of the device */
241 if (nand_scan(new_mtd, 1)) { 247 if (nand_scan(new_mtd, 1)) {
242 err = -ENXIO; 248 err = -ENXIO;
243 goto out_ior; 249 goto out_free;
244 } 250 }
245 251
246 new_mtd->name = kasprintf(GFP_KERNEL, "cs553x_nand_cs%d", cs);
247
248 cs553x_mtd[cs] = new_mtd; 252 cs553x_mtd[cs] = new_mtd;
249 goto out; 253 goto out;
250 254
255out_free:
256 kfree(new_mtd->name);
251out_ior: 257out_ior:
252 iounmap(this->IO_ADDR_R); 258 iounmap(this->IO_ADDR_R);
253out_mtd: 259out_mtd: