[PATCH 1/1] mfd: core: Fix memory leak of 'cell'

From: Lee Jones
Date: Thu Jul 16 2020 - 10:28:58 EST


When creating a platform device from an MFD cell description, we
allocate some memory and make a copy which is then stored inside the
platform_device's structure. However, care is not currently taken to
free the allocated memory when the platform device is torn down.

This patch takes care of the leak.

Signed-off-by: Lee Jones <lee.jones@xxxxxxxxxx>
---
drivers/mfd/mfd-core.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index f5a73af60dd40..e831e733b38cf 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -297,7 +297,10 @@ 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;
}

--
2.25.1