lkml.org 
[lkml]   [2011]   [Apr]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4/5] usb: gadget: f_mass_storage: Fix potential memory leak
On 04/05/2011 06:59 PM, ext Michal Nazarewicz wrote:
> On Tue, 05 Apr 2011 17:36:41 +0200, Roger Quadros
> <roger.quadros@nokia.com> wrote:
>
>> If allocation of multiple buffers would fail then we would leak memory.
>> Fix that.
>>
>> Signed-off-by: Roger Quadros <roger.quadros@nokia.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.
>

Yes it is. This patch is not required.

--
regards,
-roger


\
 
 \ /
  Last update: 2011-04-05 19:51    [W:0.049 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site