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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAECXXi7Y8XPWHaP+p67WY9GO+r5ztmmtKxF_HKFxqcE56cUieQ@mail.gmail.com>
Date:	Tue, 27 Jan 2015 09:16:51 -0500
From:	Paul Clements <paul.clements@...sios.com>
To:	Sudip Mukherjee <sudipm.mukherjee@...il.com>
Cc:	"nbd-general@...ts.sourceforge.net" 
	<nbd-general@...ts.sourceforge.net>,
	kernel list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] nbd: fix possible memory leak

On Tue, Jan 27, 2015 at 7:38 AM, Sudip Mukherjee
<sudipm.mukherjee@...il.com> wrote:
> we have already allocated memory for nbd_dev, but we were not
> releasing that memory and just returning the error value.
>
> Signed-off-by: Sudip Mukherjee <sudip@...torindia.org>

Looks good to me.

Acked-by: Paul Clements <Paul.Clements@...elEye.com>

> ---
>
> v2: moved kcalloc after the returns.
>
>  drivers/block/nbd.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index 4bc2a5c..db93c75 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -803,10 +803,6 @@ static int __init nbd_init(void)
>                 return -EINVAL;
>         }
>
> -       nbd_dev = kcalloc(nbds_max, sizeof(*nbd_dev), GFP_KERNEL);
> -       if (!nbd_dev)
> -               return -ENOMEM;
> -
>         part_shift = 0;
>         if (max_part > 0) {
>                 part_shift = fls(max_part);
> @@ -827,6 +823,10 @@ static int __init nbd_init(void)
>
>         if (nbds_max > 1UL << (MINORBITS - part_shift))
>                 return -EINVAL;
> +
> +       nbd_dev = kcalloc(nbds_max, sizeof(*nbd_dev), GFP_KERNEL);
> +       if (!nbd_dev)
> +               return -ENOMEM;
>
>         for (i = 0; i < nbds_max; i++) {
>                 struct gendisk *disk = alloc_disk(1 << part_shift);
> --
> 1.8.1.2
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ