summaryrefslogtreecommitdiff
path: root/drivers/usb/gadget
diff options
context:
space:
mode:
authorValentin Ilie <valentin.ilie@gmail.com>2013-09-21 12:30:15 +0300
committerFelipe Balbi <balbi@ti.com>2013-10-01 09:31:21 -0500
commitf51a08da6d1d591c021c1aa0ee6dd23f7caf3639 (patch)
tree9f16e51fdadf76c6deb15fe8239f611b2d72e527 /drivers/usb/gadget
parent161bfa98ba6f5b8970234e4392de1f5df4062452 (diff)
usb: gadget: mv_u3d_core: fix memory leaks
When trb_hw is NULL, trb should be free'd before return. Signed-off-by: Valentin Ilie <valentin.ilie@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r--drivers/usb/gadget/mv_u3d_core.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/usb/gadget/mv_u3d_core.c b/drivers/usb/gadget/mv_u3d_core.c
index 561b30efb8ee..4d31177d5d99 100644
--- a/drivers/usb/gadget/mv_u3d_core.c
+++ b/drivers/usb/gadget/mv_u3d_core.c
@@ -310,6 +310,7 @@ static struct mv_u3d_trb *mv_u3d_build_trb_one(struct mv_u3d_req *req,
*/
trb_hw = dma_pool_alloc(u3d->trb_pool, GFP_ATOMIC, dma);
if (!trb_hw) {
+ kfree(trb);
dev_err(u3d->dev,
"%s, dma_pool_alloc fail\n", __func__);
return NULL;
@@ -454,6 +455,7 @@ static int mv_u3d_req_to_trb(struct mv_u3d_req *req)
trb_hw = kcalloc(trb_num, sizeof(*trb_hw), GFP_ATOMIC);
if (!trb_hw) {
+ kfree(trb);
dev_err(u3d->dev,
"%s, trb_hw alloc fail\n", __func__);
return -ENOMEM;