mfd: sm501: Fix leaks in probe()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 11 Sep 2020 11:33:26 +0000 (14:33 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Oct 2020 08:07:06 +0000 (09:07 +0100)
[ Upstream commit 8ce24f8967df2836b4557a23e74dc4bb098249f1 ]

This code should clean up if sm501_init_dev() fails.

Fixes: b6d6454fdb66 ("[PATCH] mfd: SM501 core driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mfd/sm501.c

index 3270b8dbc94982ebb447d9c3ace5d1000c28a670..4ca245518a19974a847a6f2e4267ba483143d199 100644 (file)
@@ -1425,8 +1425,14 @@ static int sm501_plat_probe(struct platform_device *dev)
                goto err_claim;
        }
 
-       return sm501_init_dev(sm);
+       ret = sm501_init_dev(sm);
+       if (ret)
+               goto err_unmap;
+
+       return 0;
 
+ err_unmap:
+       iounmap(sm->regs);
  err_claim:
        release_resource(sm->regs_claim);
        kfree(sm->regs_claim);