Skip to content

Commit 4d1014c

Browse files
Filiprogrammergregkh
authored andcommitted
drivers core: Fix oops when driver probe fails
dma_range_map is freed to early, which might cause an oops when a driver probe fails. Call trace: is_free_buddy_page+0xe4/0x1d4 __free_pages+0x2c/0x88 dma_free_contiguous+0x64/0x80 dma_direct_free+0x38/0xb4 dma_free_attrs+0x88/0xa0 dmam_release+0x28/0x34 release_nodes+0x78/0x8c devres_release_all+0xa8/0x110 really_probe+0x118/0x2d0 __driver_probe_device+0xc8/0xe0 driver_probe_device+0x54/0xec __driver_attach+0xe0/0xf0 bus_for_each_dev+0x7c/0xc8 driver_attach+0x30/0x3c bus_add_driver+0x17c/0x1c4 driver_register+0xc0/0xf8 __platform_driver_register+0x34/0x40 ... This issue is introduced by commit d0243bb ("drivers core: Free dma_range_map when driver probe failed"). It frees dma_range_map before the call to devres_release_all, which is too early. The solution is to free dma_range_map only after devres_release_all. Fixes: d0243bb ("drivers core: Free dma_range_map when driver probe failed") Cc: stable <[email protected]> Signed-off-by: Filip Schauer <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ff11764 commit 4d1014c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/base/dd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,15 +653,15 @@ static int really_probe(struct device *dev, struct device_driver *drv)
653653
else if (drv->remove)
654654
drv->remove(dev);
655655
probe_failed:
656-
kfree(dev->dma_range_map);
657-
dev->dma_range_map = NULL;
658656
if (dev->bus)
659657
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
660658
BUS_NOTIFY_DRIVER_NOT_BOUND, dev);
661659
pinctrl_bind_failed:
662660
device_links_no_driver(dev);
663661
devres_release_all(dev);
664662
arch_teardown_dma_ops(dev);
663+
kfree(dev->dma_range_map);
664+
dev->dma_range_map = NULL;
665665
driver_sysfs_remove(dev);
666666
dev->driver = NULL;
667667
dev_set_drvdata(dev, NULL);

0 commit comments

Comments
 (0)