* FAILED: patch "[PATCH] pmdomain: imx: Fix reference count leak in imx_gpc_probe()" failed to apply to 6.6-stable tree
@ 2026-01-05 11:46 gregkh
2026-01-06 15:56 ` [PATCH 6.6.y 1/2] pmdomain: Use device_get_match_data() Sasha Levin
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2026-01-05 11:46 UTC (permalink / raw)
To: vulab, Frank.Li, ulf.hansson; +Cc: stable
The patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x 73cb5f6eafb0ac7aea8cdeb8ff12981aa741d8fb
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026010514-aerospace-cathouse-bd44@gregkh' --subject-prefix 'PATCH 6.6.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 73cb5f6eafb0ac7aea8cdeb8ff12981aa741d8fb Mon Sep 17 00:00:00 2001
From: Wentao Liang <vulab@iscas.ac.cn>
Date: Thu, 11 Dec 2025 04:02:52 +0000
Subject: [PATCH] pmdomain: imx: Fix reference count leak in imx_gpc_probe()
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>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
diff --git a/drivers/pmdomain/imx/gpc.c b/drivers/pmdomain/imx/gpc.c
index a34b260274f7..de695f1944ab 100644
--- a/drivers/pmdomain/imx/gpc.c
+++ b/drivers/pmdomain/imx/gpc.c
@@ -402,13 +402,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)
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 6.6.y 1/2] pmdomain: Use device_get_match_data() 2026-01-05 11:46 FAILED: patch "[PATCH] pmdomain: imx: Fix reference count leak in imx_gpc_probe()" failed to apply to 6.6-stable tree gregkh @ 2026-01-06 15:56 ` Sasha Levin 2026-01-06 15:56 ` [PATCH 6.6.y 2/2] pmdomain: imx: Fix reference count leak in imx_gpc_probe() Sasha Levin 0 siblings, 1 reply; 3+ messages in thread From: Sasha Levin @ 2026-01-06 15:56 UTC (permalink / raw) To: stable; +Cc: Rob Herring, Ulf Hansson, Sasha Levin From: Rob Herring <robh@kernel.org> [ Upstream commit 3ba9fdfaa550936837b50b73d6c27ac401fde875 ] Use preferred device_get_match_data() instead of of_match_device() to get the driver match data. With this, adjust the includes to explicitly include the correct headers. Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20231006224614.444488-1-robh@kernel.org Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Stable-dep-of: 73cb5f6eafb0 ("pmdomain: imx: Fix reference count leak in imx_gpc_probe()") Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/pmdomain/actions/owl-sps.c | 16 +++++----------- drivers/pmdomain/imx/gpc.c | 7 +++---- drivers/pmdomain/rockchip/pm-domains.c | 13 ++++--------- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/drivers/pmdomain/actions/owl-sps.c b/drivers/pmdomain/actions/owl-sps.c index 73a9e0bb7e8e..3a586d1f3256 100644 --- a/drivers/pmdomain/actions/owl-sps.c +++ b/drivers/pmdomain/actions/owl-sps.c @@ -8,8 +8,10 @@ * Copyright (c) 2017 Andreas Färber */ +#include <linux/mod_devicetable.h> #include <linux/of_address.h> -#include <linux/of_platform.h> +#include <linux/platform_device.h> +#include <linux/property.h> #include <linux/pm_domain.h> #include <linux/soc/actions/owl-sps.h> #include <dt-bindings/power/owl-s500-powergate.h> @@ -96,24 +98,16 @@ static int owl_sps_init_domain(struct owl_sps *sps, int index) static int owl_sps_probe(struct platform_device *pdev) { - const struct of_device_id *match; const struct owl_sps_info *sps_info; struct owl_sps *sps; int i, ret; - if (!pdev->dev.of_node) { - dev_err(&pdev->dev, "no device node\n"); - return -ENODEV; - } - - match = of_match_device(pdev->dev.driver->of_match_table, &pdev->dev); - if (!match || !match->data) { + sps_info = device_get_match_data(&pdev->dev); + if (!sps_info) { dev_err(&pdev->dev, "unknown compatible or missing data\n"); return -EINVAL; } - sps_info = match->data; - sps = devm_kzalloc(&pdev->dev, struct_size(sps, domains, sps_info->num_domains), GFP_KERNEL); diff --git a/drivers/pmdomain/imx/gpc.c b/drivers/pmdomain/imx/gpc.c index d7c0301a7121..9ccab78c8986 100644 --- a/drivers/pmdomain/imx/gpc.c +++ b/drivers/pmdomain/imx/gpc.c @@ -7,9 +7,10 @@ #include <linux/clk.h> #include <linux/delay.h> #include <linux/io.h> -#include <linux/of_device.h> +#include <linux/of.h> #include <linux/platform_device.h> #include <linux/pm_domain.h> +#include <linux/property.h> #include <linux/regmap.h> #include <linux/regulator/consumer.h> @@ -403,9 +404,7 @@ static int imx_gpc_old_dt_init(struct device *dev, struct regmap *regmap, static int imx_gpc_probe(struct platform_device *pdev) { - const struct of_device_id *of_id = - of_match_device(imx_gpc_dt_ids, &pdev->dev); - const struct imx_gpc_dt_data *of_id_data = of_id->data; + const struct imx_gpc_dt_data *of_id_data = device_get_match_data(&pdev->dev); struct device_node *pgc_node; struct regmap *regmap; void __iomem *base; diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c index d5d3ecb38283..9b76b62869d0 100644 --- a/drivers/pmdomain/rockchip/pm-domains.c +++ b/drivers/pmdomain/rockchip/pm-domains.c @@ -9,11 +9,13 @@ #include <linux/iopoll.h> #include <linux/err.h> #include <linux/mutex.h> +#include <linux/platform_device.h> #include <linux/pm_clock.h> #include <linux/pm_domain.h> +#include <linux/property.h> +#include <linux/of.h> #include <linux/of_address.h> #include <linux/of_clk.h> -#include <linux/of_platform.h> #include <linux/clk.h> #include <linux/regmap.h> #include <linux/mfd/syscon.h> @@ -857,7 +859,6 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev) struct device_node *node; struct device *parent; struct rockchip_pmu *pmu; - const struct of_device_id *match; const struct rockchip_pmu_info *pmu_info; int error; @@ -866,13 +867,7 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev) return -ENODEV; } - match = of_match_device(dev->driver->of_match_table, dev); - if (!match || !match->data) { - dev_err(dev, "missing pmu data\n"); - return -EINVAL; - } - - pmu_info = match->data; + pmu_info = device_get_match_data(dev); pmu = devm_kzalloc(dev, struct_size(pmu, domains, pmu_info->num_domains), -- 2.51.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 6.6.y 2/2] pmdomain: imx: Fix reference count leak in imx_gpc_probe() 2026-01-06 15:56 ` [PATCH 6.6.y 1/2] pmdomain: Use device_get_match_data() Sasha Levin @ 2026-01-06 15:56 ` Sasha Levin 0 siblings, 0 replies; 3+ messages in thread From: Sasha Levin @ 2026-01-06 15:56 UTC (permalink / raw) To: stable; +Cc: Wentao Liang, Frank Li, Ulf Hansson, Sasha Levin From: Wentao Liang <vulab@iscas.ac.cn> [ Upstream commit 73cb5f6eafb0ac7aea8cdeb8ff12981aa741d8fb ] 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> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- 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 9ccab78c8986..45625b6be62d 100644 --- a/drivers/pmdomain/imx/gpc.c +++ b/drivers/pmdomain/imx/gpc.c @@ -405,13 +405,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_read_bool(pdev->dev.of_node, "#power-domain-cells") && !pgc_node) -- 2.51.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-06 15:56 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-01-05 11:46 FAILED: patch "[PATCH] pmdomain: imx: Fix reference count leak in imx_gpc_probe()" failed to apply to 6.6-stable tree gregkh 2026-01-06 15:56 ` [PATCH 6.6.y 1/2] pmdomain: Use device_get_match_data() Sasha Levin 2026-01-06 15:56 ` [PATCH 6.6.y 2/2] pmdomain: imx: Fix reference count leak in imx_gpc_probe() Sasha Levin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox