PATCH] MTD/maps: correct cleanup in error case

vimal singh vimal.newwork at gmail.com
Fri Jul 31 01:52:07 EDT 2009


Below patch submitted to fix this along with making sure 'mtd_list' is
not being freed if it has not been allocated:

http://lists.infradead.org/pipermail/linux-mtd/2009-July/026696.html

-vimal


On Thu, Jul 30, 2009 at 8:53 PM, Benedikt
Spranger<b.spranger at linutronix.de> wrote:
> From: Benedikt Spranger <b.spranger at linutronix.de>
> 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 <b.spranger at linutronix.de>
> ---
>  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)) {
> --
> 1.6.3.3
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
>



More information about the linux-mtd mailing list