summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorHemant Kumar <hemantk@codeaurora.org>2016-05-02 10:46:49 -0700
committerKyle Yan <kyan@codeaurora.org>2016-06-10 15:13:37 -0700
commitfa1ac1406a0836c352dbf321a2429ba58dfcd51c (patch)
tree90bd1daf0facc999f7c2aec8d41a26ee4c49ab4a /drivers
parent917e41ac91a9de2c215607a054530870090a10a9 (diff)
USB: gadget: mtp: Fix bug in freeing memory on allocation failure
Current driver code doesn't handle the memory allocation failure correctly and ends up leaking memory and trying to free unallocated one. Change-Id: I7e3527b7e08ccfe566d85e3009d8a015d8daa707 Signed-off-by: Manu Gautam <mgautam@codeaurora.org> Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/gadget/function/f_mtp.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/usb/gadget/function/f_mtp.c b/drivers/usb/gadget/function/f_mtp.c
index ea3721fe73e9..f63ab883c5b9 100644
--- a/drivers/usb/gadget/function/f_mtp.c
+++ b/drivers/usb/gadget/function/f_mtp.c
@@ -552,7 +552,7 @@ retry_rx_alloc:
if (!req) {
if (mtp_rx_req_len <= MTP_BULK_BUFFER_SIZE)
goto fail;
- for (; i > 0; i--)
+ for (--i; i >= 0; i--)
mtp_request_free(dev->rx_req[i], dev->ep_out);
mtp_rx_req_len = MTP_BULK_BUFFER_SIZE;
goto retry_rx_alloc;