These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / mtd / nand / cs553x_nand.c
index 88109d3..aec6045 100644 (file)
@@ -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 */
        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 */
        if (nand_scan(new_mtd, 1)) {
                err = -ENXIO;
-               goto out_ior;
+               goto out_free;
        }
 
-       new_mtd->name = kasprintf(GFP_KERNEL, "cs553x_nand_cs%d", cs);
-
        cs553x_mtd[cs] = new_mtd;
        goto out;
 
+out_free:
+       kfree(new_mtd->name);
 out_ior:
        iounmap(this->IO_ADDR_R);
 out_mtd: