lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.0911212243420.28848@ask.diku.dk>
Date:	Sat, 21 Nov 2009 22:44:08 +0100 (CET)
From:	Julia Lawall <julia@...u.dk>
To:	Dan Williams <dan.j.williams@...el.com>
Cc:	maciej.sosnowski@...el.com, linux-kernel@...r.kernel.org,
	kernel-janitors@...r.kernel.org,
	Nobuhiro Iwamatsu <iwamatsu.nobuhiro@...esas.com>
Subject: Re: [PATCH 7/8] drivers/dma: introduce missing kfree

On Sat, 21 Nov 2009, Dan Williams wrote:

> On Sat, Nov 21, 2009 at 4:52 AM, Julia Lawall <julia@...u.dk> wrote:
> > From: Julia Lawall <julia@...u.dk>
> >
> > Error handling code following a kzalloc should free the allocated data.
> >
> 
> Yes, but there is another buglet here:
> 
> >        /* get platform data */
> >        if (!pdev->dev.platform_data)
> > -               goto shdev_err;
> > +               goto platform_err;
> 
> "err" is still zero at this point so the probe does not fail.
> 
> How about the following instead?

OK, that is indeed both better and simpler.

thanks,
julia


> diff --git a/drivers/dma/shdma.c b/drivers/dma/shdma.c
> index b3b065c..034ecf0 100644
> --- a/drivers/dma/shdma.c
> +++ b/drivers/dma/shdma.c
> @@ -640,17 +640,16 @@ static int __init sh_dmae_probe(struct
> platform_device *pdev)
>  #endif
>         struct sh_dmae_device *shdev;
> 
> +       /* get platform data */
> +       if (!pdev->dev.platform_data)
> +               return -ENODEV;
> +
>         shdev = kzalloc(sizeof(struct sh_dmae_device), GFP_KERNEL);
>         if (!shdev) {
>                 dev_err(&pdev->dev, "No enough memory\n");
> -               err = -ENOMEM;
> -               goto shdev_err;
> +               return -ENOMEM;
>         }
> 
> -       /* get platform data */
> -       if (!pdev->dev.platform_data)
> -               goto shdev_err;
> -
>         /* platform data */
>         memcpy(&shdev->pdata, pdev->dev.platform_data,
>                         sizeof(struct sh_dmae_pdata));
> @@ -722,7 +721,6 @@ eirq_err:
>  rst_err:
>         kfree(shdev);
> 
> -shdev_err:
>         return err;
>  }
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ