Skip to content

Commit

Permalink
usb: gadget: bdc: fix memory leak
Browse files Browse the repository at this point in the history
If dma_pool_alloc() fails we are jumping to fail and releasing all the
bd_tables which have been added to the chain but we missed freeing this
bd_table which was just allocated and still not added to the chain of
bd_table.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Sudip Mukherjee authored and Felipe Balbi committed Sep 30, 2015
1 parent 9ffecb1 commit 7022cfd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/usb/gadget/udc/bdc/bdc_ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,10 @@ static int ep_bd_list_alloc(struct bdc_ep *ep)
bd_table->start_bd = dma_pool_alloc(bdc->bd_table_pool,
GFP_ATOMIC,
&dma);
if (!bd_table->start_bd)
if (!bd_table->start_bd) {
kfree(bd_table);
goto fail;
}

bd_table->dma = dma;

Expand Down

0 comments on commit 7022cfd

Please sign in to comment.