Re: [PATCH 2/4] ARM: OMAP2+: gpmc-nand: fix error unwinding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 11/02/17 15:02, Ladislav Michl wrote:
> Do not call platform_device_put if platform_device_alloc
> failed to allocate.
> 

It doesn't matter if platform_device_put is called if
platform_device_alloc fails as it checks for NULL pdev internally.

Did you face any issues without this patch?

> Signed-off-by: Ladislav Michl <ladis@xxxxxxxxxxxxxx>
> ---
>  arch/arm/mach-omap2/gpmc-nand.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/gpmc-nand.c b/arch/arm/mach-omap2/gpmc-nand.c
> index f6ac027f3c3b..221c9d319880 100644
> --- a/arch/arm/mach-omap2/gpmc-nand.c
> +++ b/arch/arm/mach-omap2/gpmc-nand.c
> @@ -126,17 +126,18 @@ int gpmc_nand_init(struct omap_nand_platform_data *gpmc_nand_data,
>  
>  
>  	pdev = platform_device_alloc("omap2-nand", gpmc_nand_data->cs);
> -	if (pdev) {
> -		err = platform_device_add_resources(pdev, gpmc_nand_res,
> -						    ARRAY_SIZE(gpmc_nand_res));
> -		if (!err)
> -			pdev->dev.platform_data = gpmc_nand_data;
> -	} else {
> +	if (!pdev) {
>  		err = -ENOMEM;
> +		goto out_free_cs;
>  	}
> +
> +	err = platform_device_add_resources(pdev, gpmc_nand_res,
> +					    ARRAY_SIZE(gpmc_nand_res));
>  	if (err)
>  		goto out_free_pdev;
>  
> +	pdev->dev.platform_data = gpmc_nand_data;
> +
>  	err = platform_device_add(pdev);
>  	if (err) {
>  		dev_err(&pdev->dev, "Unable to register NAND device\n");
> 

-- 
cheers,
-roger
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux