From: Simon Glass <sjg@chromium.org> The sandbox I2C PMIC emulator allocates a register buffer in its probe function but has no remove function to free it. Add a remove handler to free the buffer when the device is removed. Fixes: eb7387ae14ef ("sandbox: pmic: Correct i2c pmic emulator platdata method") Signed-off-by: Simon Glass <sjg@chromium.org> --- drivers/power/pmic/i2c_pmic_emul.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/power/pmic/i2c_pmic_emul.c b/drivers/power/pmic/i2c_pmic_emul.c index 6e81b9c3427..dd0ec39ef48 100644 --- a/drivers/power/pmic/i2c_pmic_emul.c +++ b/drivers/power/pmic/i2c_pmic_emul.c @@ -146,6 +146,16 @@ static int sandbox_i2c_pmic_probe(struct udevice *emul) return 0; } +static int sandbox_i2c_pmic_remove(struct udevice *emul) +{ + struct sandbox_i2c_pmic_plat_data *plat = dev_get_plat(emul); + + free(plat->reg); + plat->reg = NULL; + + return 0; +} + struct dm_i2c_ops sandbox_i2c_pmic_emul_ops = { .xfer = sandbox_i2c_pmic_xfer, }; @@ -161,6 +171,7 @@ U_BOOT_DRIVER(sandbox_i2c_pmic_emul) = { .of_match = sandbox_i2c_pmic_ids, .of_to_plat = sandbox_i2c_pmic_of_to_plat, .probe = sandbox_i2c_pmic_probe, + .remove = sandbox_i2c_pmic_remove, .plat_auto = sizeof(struct sandbox_i2c_pmic_plat_data), .ops = &sandbox_i2c_pmic_emul_ops, }; -- 2.43.0