1
0
mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2026-01-11 09:00:12 +00:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Linus Torvalds
aacb0a6d60 pmdomain providers:
- mediatek: Fix spinlock recursion fix during probe
  - imx: Fix reference count leak during probe
 -----BEGIN PGP SIGNATURE-----
 
 iQJLBAABCgA1FiEEugLDXPmKSktSkQsV/iaEJXNYjCkFAmlY4tEXHHVsZi5oYW5z
 c29uQGxpbmFyby5vcmcACgkQ/iaEJXNYjCmMGw/+OeVTe98SuoLT01SHR46R50XN
 QCxuhVoWH0KYBI6+nmcRSKeY1jSnrBmKKX6LqMIfHXv1lXCU92dbfHuthfN3saaF
 zV0YskGlQHZ3+4B+lL3Ojf7PlRVBF28fuplGA7ci4j3P3sgAds5kly/kcsllXs2x
 IiVIyahfPwA8eu6x36aBnDs/IXn11EOdhBA4jqRy09XKgRtLG1qCDl27UmmguyB7
 GGtivGZOihXSp7BciAIFenpNElsDUdkj7ftyoVkl25Ixt+VMP8yqVCLd6S512tqg
 uqprxPJKM3nUtVV5NRYK9l7DDUxCdNWsrX9aONiUmkZLj2gzTDuz7evoV3uwajJ+
 6vzJFldv52L2pm/ENc8SUbdtvTCM7Gv8JVwmud+i8mAHVaqmOf4mAIpvlChet3RX
 2d8RsqrEPe/i8TPsgBymrkSjpBm595sM25zzZYG2+Dgx3Paid5pTEvtjvhk0JGRc
 UgKoARfHIkzWFoOdbyguvK84xpFG2hOGcc89qMAnej7pggRZmZCmFzbPDbp2+cvp
 U37lVp2C0D53yO/jHOJZ78/VZbQv2W2qgKJzL4CWN5CiaAXFnaH98tJ7Rm/bEECe
 vRG9xTgRaNhUOY6W+HHp2c8MZQNDKZ5T3uBhbzdZUN+NwzXqUdgsj19Fbh/1ZX0w
 RYSHgVXaOqhZRyXt8mM=
 =0il+
 -----END PGP SIGNATURE-----

Merge tag 'pmdomain-v6.19-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/linux-pm

Pull pmdomain fixes from Ulf Hansson:

 - mediatek: Fix spinlock recursion fix during probe

 - imx: Fix reference count leak during probe

* tag 'pmdomain-v6.19-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/linux-pm:
  pmdomain: imx: Fix reference count leak in imx_gpc_probe()
  pmdomain: mtk-pm-domains: Fix spinlock recursion fix in probe
2026-01-03 09:18:36 -08:00
Wentao Liang
73cb5f6eaf 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>
2025-12-29 11:41:09 +01:00
Macpaul Lin
305f254727 pmdomain: mtk-pm-domains: Fix spinlock recursion fix in probe
Remove scpsys_get_legacy_regmap(), replacing its usage with
of_find_node_with_property(). Explicitly call of_node_get(np) before each
of_find_node_with_property() to maintain correct node reference counting.

The of_find_node_with_property() function "consumes" its input by calling
of_node_put() internally, whether or not it finds a match.  Currently,
dev->of_node (np) is passed multiple times in sequence without incrementing
its reference count, causing it to be decremented multiple times and
risking early memory release.

Adding of_node_get(np) before each call balances the reference count,
preventing premature node release.

Fixes: c1bac49fe91f ("pmdomains: mtk-pm-domains: Fix spinlock recursion in probe")
Cc: stable@vger.kernel.org
Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>
Tested-by: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-12-29 11:41:09 +01:00
2 changed files with 8 additions and 18 deletions

View File

@ -402,13 +402,12 @@ clk_err:
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)

View File

@ -984,18 +984,6 @@ static void scpsys_domain_cleanup(struct scpsys *scpsys)
}
}
static struct device_node *scpsys_get_legacy_regmap(struct device_node *np, const char *pn)
{
struct device_node *local_node;
for_each_child_of_node(np, local_node) {
if (of_property_present(local_node, pn))
return local_node;
}
return NULL;
}
static int scpsys_get_bus_protection_legacy(struct device *dev, struct scpsys *scpsys)
{
const u8 bp_blocks[3] = {
@ -1017,7 +1005,8 @@ static int scpsys_get_bus_protection_legacy(struct device *dev, struct scpsys *s
* this makes it then possible to allocate the array of bus_prot
* regmaps and convert all to the new style handling.
*/
node = scpsys_get_legacy_regmap(np, "mediatek,infracfg");
of_node_get(np);
node = of_find_node_with_property(np, "mediatek,infracfg");
if (node) {
regmap[0] = syscon_regmap_lookup_by_phandle(node, "mediatek,infracfg");
of_node_put(node);
@ -1030,7 +1019,8 @@ static int scpsys_get_bus_protection_legacy(struct device *dev, struct scpsys *s
regmap[0] = NULL;
}
node = scpsys_get_legacy_regmap(np, "mediatek,smi");
of_node_get(np);
node = of_find_node_with_property(np, "mediatek,smi");
if (node) {
smi_np = of_parse_phandle(node, "mediatek,smi", 0);
of_node_put(node);
@ -1048,7 +1038,8 @@ static int scpsys_get_bus_protection_legacy(struct device *dev, struct scpsys *s
regmap[1] = NULL;
}
node = scpsys_get_legacy_regmap(np, "mediatek,infracfg-nao");
of_node_get(np);
node = of_find_node_with_property(np, "mediatek,infracfg-nao");
if (node) {
regmap[2] = syscon_regmap_lookup_by_phandle(node, "mediatek,infracfg-nao");
num_regmaps++;