[PATCH V2 3/8] mtd: lantiq-flash: Use devm_kzalloc()

Ezequiel Garcia ezequiel.garcia at free-electrons.com
Fri Dec 20 10:38:17 EST 2013


On Fri, Dec 20, 2013 at 04:32:41PM +0900, Jingoo Han wrote:
> Use devm_kzalloc() to make cleanup paths simpler.
> 
> Signed-off-by: Jingoo Han <jg1.han at samsung.com>
> ---
> Change since v1
> - Remove unnecessary goto labels.
> 
>  drivers/mtd/maps/lantiq-flash.c |   31 ++++++++++---------------------
>  1 file changed, 10 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/mtd/maps/lantiq-flash.c b/drivers/mtd/maps/lantiq-flash.c
> index d7ac65d..45a7ac7 100644
> --- a/drivers/mtd/maps/lantiq-flash.c
> +++ b/drivers/mtd/maps/lantiq-flash.c
> @@ -123,24 +123,22 @@ ltq_mtd_probe(struct platform_device *pdev)
>  		return -ENODEV;
>  	}
>  
> -	ltq_mtd = kzalloc(sizeof(struct ltq_mtd), GFP_KERNEL);
> +	ltq_mtd = devm_kzalloc(&pdev->dev, sizeof(struct ltq_mtd), GFP_KERNEL);

And you don't check if the allocation succeded?

>  	platform_set_drvdata(pdev, ltq_mtd);
>  
>  	ltq_mtd->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	if (!ltq_mtd->res) {
>  		dev_err(&pdev->dev, "failed to get memory resource\n");
> -		err = -ENOENT;
> -		goto err_out;
> +		return -ENOENT;
>  	}
>  
> -	ltq_mtd->map = kzalloc(sizeof(struct map_info), GFP_KERNEL);
> +	ltq_mtd->map = devm_kzalloc(&pdev->dev, sizeof(struct map_info),
> +				    GFP_KERNEL);

Ditto.

I think that's a far more urgent fix, than moving to devm_kzalloc.
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com



More information about the linux-mtd mailing list