]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
regulator: s5m8767: Fix reference count leak
authorPan Bian <bianpan2016@163.com>
Thu, 21 Jan 2021 03:27:56 +0000 (19:27 -0800)
committerAndrea Righi <andrea.righi@canonical.com>
Mon, 15 Mar 2021 14:09:19 +0000 (15:09 +0100)
[ Upstream commit dea6dd2ba63f8c8532addb8f32daf7b89a368a42 ]

Call of_node_put() to drop references of regulators_np and reg_np before
returning error code.

Fixes: 9ae5cc75ceaa ("regulator: s5m8767: Pass descriptor instead of GPIO number")
Signed-off-by: Pan Bian <bianpan2016@163.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Link: https://lore.kernel.org/r/20210121032756.49501-1-bianpan2016@163.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
drivers/regulator/s5m8767.c

index 3fa472127e9a167a5f60ea3885e8e08bd3880911..48dd95b3ff45a84580b9a6607f53c9c580f0840b 100644 (file)
@@ -573,10 +573,13 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
                        "s5m8767,pmic-ext-control",
                        GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE,
                        "s5m8767");
-               if (PTR_ERR(rdata->ext_control_gpiod) == -ENOENT)
+               if (PTR_ERR(rdata->ext_control_gpiod) == -ENOENT) {
                        rdata->ext_control_gpiod = NULL;
-               else if (IS_ERR(rdata->ext_control_gpiod))
+               } else if (IS_ERR(rdata->ext_control_gpiod)) {
+                       of_node_put(reg_np);
+                       of_node_put(regulators_np);
                        return PTR_ERR(rdata->ext_control_gpiod);
+               }
 
                rdata->id = i;
                rdata->initdata = of_get_regulator_init_data(