diff options
| author | Dan Carpenter <dan.carpenter@linaro.org> | 2025-05-27 08:44:14 +0300 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-06-27 11:07:22 +0100 |
| commit | 004b05e954a2180a59e323b8378410a2c48799d7 (patch) | |
| tree | d8f7d9e4d7e560763e817b210ccf3d64dbd8f93d /drivers/regulator | |
| parent | 9ae9cfd1834e69ecdb7b33686042aaec12b3e219 (diff) | |
| download | linux-004b05e954a2180a59e323b8378410a2c48799d7.tar.gz linux-004b05e954a2180a59e323b8378410a2c48799d7.tar.bz2 linux-004b05e954a2180a59e323b8378410a2c48799d7.zip | |
regulator: max20086: Fix refcount leak in max20086_parse_regulators_dt()
[ Upstream commit 06118ae36855b7d3d22688298e74a766ccf0cb7a ]
There is a missing call to of_node_put() if devm_kcalloc() fails.
Fix this by changing the code to use cleanup.h magic to drop the
refcount.
Fixes: 6b0cd72757c6 ("regulator: max20086: fix invalid memory access")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://patch.msgid.link/aDVRLqgJWMxYU03G@stanley.mountain
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/regulator')
| -rw-r--r-- | drivers/regulator/max20086-regulator.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/regulator/max20086-regulator.c b/drivers/regulator/max20086-regulator.c index 332fb58f9095..a24dfffce25c 100644 --- a/drivers/regulator/max20086-regulator.c +++ b/drivers/regulator/max20086-regulator.c @@ -5,6 +5,7 @@ // Copyright (C) 2022 Laurent Pinchart <laurent.pinchart@idesonboard.com> // Copyright (C) 2018 Avnet, Inc. +#include <linux/cleanup.h> #include <linux/err.h> #include <linux/gpio.h> #include <linux/gpio/consumer.h> @@ -134,11 +135,11 @@ static int max20086_regulators_register(struct max20086 *chip) static int max20086_parse_regulators_dt(struct max20086 *chip, bool *boot_on) { struct of_regulator_match *matches; - struct device_node *node; unsigned int i; int ret; - node = of_get_child_by_name(chip->dev->of_node, "regulators"); + struct device_node *node __free(device_node) = + of_get_child_by_name(chip->dev->of_node, "regulators"); if (!node) { dev_err(chip->dev, "regulators node not found\n"); return -ENODEV; @@ -154,7 +155,6 @@ static int max20086_parse_regulators_dt(struct max20086 *chip, bool *boot_on) ret = of_regulator_match(chip->dev, node, matches, chip->info->num_outputs); - of_node_put(node); if (ret < 0) { dev_err(chip->dev, "Failed to match regulators\n"); return -EINVAL; |
