Messages in this thread | | | Date | Tue, 5 Apr 2011 20:47:44 +0300 | From | Roger Quadros <> | Subject | Re: [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
| |