]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
Platform: OLPC: Fix memleak in olpc_ec_probe
authorDinghao Liu <dinghao.liu@zju.edu.cn>
Sun, 23 Aug 2020 11:12:11 +0000 (19:12 +0800)
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 24 Sep 2020 09:40:30 +0000 (12:40 +0300)
When devm_regulator_register() fails, ec should be
freed just like when olpc_ec_cmd() fails.

Fixes: 231c0c216172a ("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>
drivers/platform/olpc/olpc-ec.c

index 190e4a6186ef7ffe7a93754e54c9cda38b51f646..f64b82824db28225380b13bdfb23c1b19b9445d0 100644 (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();