Skip to contentSkip to conversation

usb: gadget: bdc: fix memory leak

PATCH New Sudip Mukherjee 1 participant 1 message Sep 26, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: gadget: bdc: fix memory leak

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.

---
 drivers/usb/gadget/udc/bdc/bdc_ep.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/gadget/udc/bdc/bdc_ep.c +3 -1
index d1b8153..97b7648 100644
@@ -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;
 
Signature · 1 line
1.9.1