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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <op.vtg2p4fl3l0zgt@mnazarewicz-glaptop>
Date:	Tue, 05 Apr 2011 17:59:54 +0200
From:	"Michal Nazarewicz" <mina86@...a86.com>
To:	gregkh@...e.de, "Roger Quadros" <roger.quadros@...ia.com>
Cc:	linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 4/5] usb: gadget: f_mass_storage: Fix potential memory
 leak

On Tue, 05 Apr 2011 17:36:41 +0200, Roger Quadros  
<roger.quadros@...ia.com> wrote:

> If allocation of multiple buffers would fail then we would leak memory.
> Fix that.
>
> Signed-off-by: Roger Quadros <roger.quadros@...ia.com>
> ---
>  drivers/usb/gadget/f_mass_storage.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/usb/gadget/f_mass_storage.c  
> b/drivers/usb/gadget/f_mass_storage.c
> index f6bd001..60b4df9 100644
> --- a/drivers/usb/gadget/f_mass_storage.c
> +++ b/drivers/usb/gadget/f_mass_storage.c
> @@ -2863,6 +2863,12 @@ buffhds_first_it:
>  		bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL);
>  		if (unlikely(!bh->buf)) {
>  			rc = -ENOMEM;
> +			/* clean up */
> +			while (i < FSG_NUM_BUFFERS) {
> +				bh--;
> +				kfree(bh->buf);
> +				i++;
> +			}
>  			goto error_release;
>  		}
>  	} while (--i);

This is handled in fsg_common_release(), isn't it?  Feel free to
send a patch with a comment explaining that.

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michal "mina86" Nazarewicz    (o o)
ooo +-----<email/xmpp: mnazarewicz@...gle.com>-----ooO--(_)--Ooo--
--
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