Skip to content

Commit d0243bb

Browse files
limeng-linuxgregkh
authored andcommitted
drivers core: Free dma_range_map when driver probe failed
There will be memory leak if driver probe failed. Trace as below: backtrace: [<000000002415258f>] kmemleak_alloc+0x3c/0x50 [<00000000f447ebe4>] __kmalloc+0x208/0x530 [<0000000048bc7b3a>] of_dma_get_range+0xe4/0x1b0 [<0000000041e39065>] of_dma_configure_id+0x58/0x27c [<000000006356866a>] platform_dma_configure+0x2c/0x40 ...... [<000000000afcf9b5>] ret_from_fork+0x10/0x3c This issue is introduced by commit e0d0727("dma-mapping: introduce DMA range map, supplanting dma_pfn_offset "). It doesn't free dma_range_map when driver probe failed and cause above memory leak. So, add code to free it in error path. Fixes: e0d0727 ("dma-mapping: introduce DMA range map, supplanting dma_pfn_offset ") Cc: [email protected] Signed-off-by: Meng Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e71ba94 commit d0243bb

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/base/dd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,8 @@ static int really_probe(struct device *dev, struct device_driver *drv)
619619
else if (drv->remove)
620620
drv->remove(dev);
621621
probe_failed:
622+
kfree(dev->dma_range_map);
623+
dev->dma_range_map = NULL;
622624
if (dev->bus)
623625
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
624626
BUS_NOTIFY_DRIVER_NOT_BOUND, dev);

0 commit comments

Comments
 (0)