Commit f51a08da authored by Valentin Ilie's avatar Valentin Ilie Committed by Felipe Balbi

usb: gadget: mv_u3d_core: fix memory leaks

When trb_hw is NULL, trb should be free'd before return.
Signed-off-by: default avatarValentin Ilie <valentin.ilie@gmail.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 161bfa98
...@@ -310,6 +310,7 @@ static struct mv_u3d_trb *mv_u3d_build_trb_one(struct mv_u3d_req *req, ...@@ -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); trb_hw = dma_pool_alloc(u3d->trb_pool, GFP_ATOMIC, dma);
if (!trb_hw) { if (!trb_hw) {
kfree(trb);
dev_err(u3d->dev, dev_err(u3d->dev,
"%s, dma_pool_alloc fail\n", __func__); "%s, dma_pool_alloc fail\n", __func__);
return NULL; return NULL;
...@@ -454,6 +455,7 @@ static int mv_u3d_req_to_trb(struct mv_u3d_req *req) ...@@ -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); trb_hw = kcalloc(trb_num, sizeof(*trb_hw), GFP_ATOMIC);
if (!trb_hw) { if (!trb_hw) {
kfree(trb);
dev_err(u3d->dev, dev_err(u3d->dev,
"%s, trb_hw alloc fail\n", __func__); "%s, trb_hw alloc fail\n", __func__);
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment