From: Frank Li <Frank.li@nxp.com>
To: Wentao Liang <vulab@iscas.ac.cn>
Cc: ulf.hansson@linaro.org, shawnguo@kernel.org,
s.hauer@pengutronix.de, kernel@pengutronix.de,
festevam@gmail.com, linux-pm@vger.kernel.org,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v4] pmdomain: imx: Fix reference count leak in imx_gpc_probe()
Date: Thu, 11 Dec 2025 11:57:04 -0500 [thread overview]
Message-ID: <aTr34BiVU+xPvuq9@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20251211040252.497759-1-vulab@iscas.ac.cn>
On Thu, Dec 11, 2025 at 04:02:52AM +0000, Wentao Liang wrote:
> of_get_child_by_name() returns a node pointer with refcount incremented.
> Use the __free() attribute to manage the pgc_node reference, ensuring
> automatic of_node_put() cleanup when pgc_node goes out of scope.
>
> This eliminates the need for explicit error handling paths and avoids
> reference count leaks.
>
> Fixes: 721cabf6c660 ("soc: imx: move PGC handling to a new GPC driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
>
> ---
> Change in V4:
> - Fix typo error in code
>
> Change in V3:
> - Ensure variable is assigned when using cleanup attribute
>
> Change in V2:
> - Use __free() attribute instead of explicit of_node_put() calls
> ---
> drivers/pmdomain/imx/gpc.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pmdomain/imx/gpc.c b/drivers/pmdomain/imx/gpc.c
> index f18c7e6e75dd..56a78cc86584 100644
> --- a/drivers/pmdomain/imx/gpc.c
> +++ b/drivers/pmdomain/imx/gpc.c
> @@ -403,13 +403,12 @@ static int imx_gpc_old_dt_init(struct device *dev, struct regmap *regmap,
> static int imx_gpc_probe(struct platform_device *pdev)
> {
> const struct imx_gpc_dt_data *of_id_data = device_get_match_data(&pdev->dev);
> - struct device_node *pgc_node;
> + struct device_node *pgc_node __free(device_node)
> + = of_get_child_by_name(pdev->dev.of_node, "pgc");
> struct regmap *regmap;
> void __iomem *base;
> int ret;
>
> - pgc_node = of_get_child_by_name(pdev->dev.of_node, "pgc");
> -
> /* bail out if DT too old and doesn't provide the necessary info */
> if (!of_property_present(pdev->dev.of_node, "#power-domain-cells") &&
> !pgc_node)
> --
> 2.34.1
>
next prev parent reply other threads:[~2025-12-11 16:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-11 4:02 [PATCH v4] pmdomain: imx: Fix reference count leak in imx_gpc_probe() Wentao Liang
2025-12-11 16:57 ` Frank Li [this message]
2025-12-28 15:51 ` Ulf Hansson
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=aTr34BiVU+xPvuq9@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=stable@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
--cc=vulab@iscas.ac.cn \
/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