Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>

authored by

Sudip Mukherjee and committed by
Felipe Balbi
7022cfdf 9ffecb10

+3 -1
+3 -1
drivers/usb/gadget/udc/bdc/bdc_ep.c
··· 159 159 bd_table->start_bd = dma_pool_alloc(bdc->bd_table_pool, 160 160 GFP_ATOMIC, 161 161 &dma); 162 - if (!bd_table->start_bd) 162 + if (!bd_table->start_bd) { 163 + kfree(bd_table); 163 164 goto fail; 165 + } 164 166 165 167 bd_table->dma = dma; 166 168