Message ID | 20170211130212.cnyuxqczf5l33g6b@lenoch (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
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@linux-mips.org> > --- > 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"); >
Hi Roger, On Tue, Feb 14, 2017 at 12:02:19PM +0200, Roger Quadros wrote: > 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? No, it just makes things to look more likely an error unwinding pattern which is IMHO easier to read. I'm not pushing to include this patch as I made it while looking for differences between probing NAND and OneNAND. Best reards, ladis -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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");
Do not call platform_device_put if platform_device_alloc failed to allocate. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> --- arch/arm/mach-omap2/gpmc-nand.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)