Platform: OLPC: Fix memleak in olpc_ec_probe

When devm_regulator_register() fails, ec should be
freed just like when olpc_ec_cmd() fails.

Fixes: 231c0c2161 ("Platform: OLPC: Add a regulator for the DCON")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
This commit is contained in:
Dinghao Liu 2020-08-23 19:12:11 +08:00 committed by Andy Shevchenko
parent 9123e3a74e
commit 4fd9ac6bd3
1 changed files with 3 additions and 1 deletions

View File

@ -439,7 +439,9 @@ static int olpc_ec_probe(struct platform_device *pdev)
&config);
if (IS_ERR(ec->dcon_rdev)) {
dev_err(&pdev->dev, "failed to register DCON regulator\n");
return PTR_ERR(ec->dcon_rdev);
err = PTR_ERR(ec->dcon_rdev);
kfree(ec);
return err;
}
ec->dbgfs_dir = olpc_ec_setup_debugfs();