OSDN Git Service

mfd: core: Fix double-free in mfd_remove_devices_fn()
authorDmitry Osipenko <digetx@gmail.com>
Mon, 17 Aug 2020 23:50:48 +0000 (02:50 +0300)
committerLee Jones <lee.jones@linaro.org>
Mon, 24 Aug 2020 13:23:55 +0000 (14:23 +0100)
The pdev.mfd_cell is released by platform_device_release(), which is
invoked by platform_device_unregister(). Hence mfd_remove_devices_fn()
shouldn't release the cell variable. The double-free bug is reported KASAN
during of MFD driver module removal.

Fixes: 466a62d7642f ("mfd: core: Make a best effort attempt to match devices with the correct of_nodes")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/mfd/mfd-core.c

index c3651f0..c50718e 100644 (file)
@@ -370,8 +370,6 @@ static int mfd_remove_devices_fn(struct device *dev, void *data)
        regulator_bulk_unregister_supply_alias(dev, cell->parent_supplies,
                                               cell->num_parent_supplies);
 
-       kfree(cell);
-
        platform_device_unregister(pdev);
        return 0;
 }