From patchwork Thu Jul 30 15:23:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: PATCH] MTD/maps: correct cleanup in error case Date: Thu, 30 Jul 2009 05:23:10 -0000 From: Benedikt Spranger X-Patchwork-Id: 30389 Message-Id: <20090730172310.719ad329@ariane.spranger.biz> To: linux-mtd@lists.infradead.org Cc: Stoyan Gaydarov , dwmw2@infradead.org From: Benedikt Spranger Date: Thu, 30 Jul 2009 17:03:51 +0200 Subject: [PATCH] MTD/maps: correct cleanup in error case fix a copy and paste error introduced by commit 143070e (mtd: physmap_of: Add multiple regions and concatenation support). info is needed (via drvdata) and freed in of_flash_remove(), therefore drvdata should be set right after allocation. Signed-off-by: Benedikt Spranger --- drivers/mtd/maps/physmap_of.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c index 39d357b..32b4a5a 100644 --- a/drivers/mtd/maps/physmap_of.c +++ b/drivers/mtd/maps/physmap_of.c @@ -214,12 +214,12 @@ static int __devinit of_flash_probe(struct of_device *dev, if (!info) goto err_out; + dev_set_drvdata(&dev->dev, info); + mtd_list = kzalloc(sizeof(struct mtd_info) * count, GFP_KERNEL); - if (!info) + if (!mtd_list) goto err_out; - dev_set_drvdata(&dev->dev, info); - for (i = 0; i < count; i++) { err = -ENXIO; if (of_address_to_resource(dp, i, &res)) {