From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Cosmin Tanislav <demonsingur@gmail.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] regulator: max20086: Fix refcount leak in max20086_parse_regulators_dt()
Date: Tue, 27 May 2025 14:15:22 +0200 [thread overview]
Message-ID: <20250527121522.GN12492@pendragon.ideasonboard.com> (raw)
In-Reply-To: <aDVRLqgJWMxYU03G@stanley.mountain>
Hi Dan,
Thank you for the patch.
On Tue, May 27, 2025 at 08:44:14AM +0300, Dan Carpenter wrote:
> 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>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> drivers/regulator/max20086-regulator.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/regulator/max20086-regulator.c b/drivers/regulator/max20086-regulator.c
> index b4fe76e33ff2..fcdd2d0317a5 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/consumer.h>
> #include <linux/i2c.h>
> @@ -133,11 +134,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;
> @@ -153,7 +154,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;
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2025-05-27 12:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-27 5:44 [PATCH] regulator: max20086: Fix refcount leak in max20086_parse_regulators_dt() Dan Carpenter
2025-05-27 12:15 ` Laurent Pinchart [this message]
2025-06-09 13:40 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250527121522.GN12492@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=broonie@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=demonsingur@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox