[PATCH V2 3/8] mtd: lantiq-flash: Use devm_kzalloc()
Jingoo Han
jg1.han at samsung.com
Wed Dec 25 20:24:41 EST 2013
On Saturday, December 21, 2013 12:38 AM, Ezequiel Garcia wrote:
> 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.
OK, I see.
Although I think that checking return value can be sent as
another patch, I will add this to the next v3 patch.
Thank you for your comment.
Best regards,
Jingoo Han
More information about the linux-mtd
mailing list