Skip to contentSkip to conversation

clk: at91: check pmc node status before registering syscore ops

PATCH Applied Clément Léger 4 participants 6 messages Sep 13, 2021 – Oct 8, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: at91: check pmc node status before registering syscore ops

Currently, at91 pmc driver always register the syscore_ops whatever the status of the pmc node that has been found. When set as secure and disabled, the pmc should not be accessed or this will generate abort exceptions.
To avoid this, add a check on node availability before registering the syscore operations.

---
 drivers/clk/at91/pmc.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/clk/at91/pmc.c +5 -0
index 20ee9dccee78..b40035b011d0 100644
@@ -267,6 +267,11 @@ static int __init pmc_register_ops(void)
 	if (!np)
 		return -ENODEV;
 
+	if (!of_device_is_available(np)) {
+		of_node_put(np);
+		return -ENODEV;
+	}
+
 	pmcreg = device_node_to_regmap(np);
 	of_node_put(np);
 	if (IS_ERR(pmcreg))
Signature · 1 line
2.33.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Clément Léger

Currently, at91 pmc driver always register the syscore_ops whatever the status of the pmc node that has been found. When set as secure and disabled, the pmc should not be accessed or this will generate abort exceptions.
To avoid this, add a check on node availability before registering the syscore operations.

Yes, indeed,

Thanks, best regards,
Nicolas

Quoted 23 lines
---
  drivers/clk/at91/pmc.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/clk/at91/pmc.c +5 -1
index 20ee9dccee78..b40035b011d0 100644
@@ -267,6 +267,11 @@ static int __init pmc_register_ops(void)
         if (!np)
                 return -ENODEV;
 
+       if (!of_device_is_available(np)) {
+               of_node_put(np);
+               return -ENODEV;
+       }
+
         pmcreg = device_node_to_regmap(np);
         of_node_put(np);
         if (IS_ERR(pmcreg))
--

2.33.0

Signature · 1 line
Nicolas Ferre
Reviewed-by on v1 1/1
#2 lore raw
In reply to Clément Léger
Quoted 10 lines · Clément Léger

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Currently, at91 pmc driver always register the syscore_ops whatever the status of the pmc node that has been found. When set as secure and disabled, the pmc should not be accessed or this will generate abort exceptions.
To avoid this, add a check on node availability before registering the syscore operations.

Quoted 21 lines
---
 drivers/clk/at91/pmc.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/clk/at91/pmc.c +5 -1
index 20ee9dccee78..b40035b011d0 100644
@@ -267,6 +267,11 @@ static int __init pmc_register_ops(void)
        if (!np)
                return -ENODEV;
 
+       if (!of_device_is_available(np)) {
+               of_node_put(np);
+               return -ENODEV;
+       }
+
        pmcreg = device_node_to_regmap(np);
        of_node_put(np);
        if (IS_ERR(pmcreg))
--
Quoted 2 lines

2.33.0

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer
#3 lore raw
In reply to Clément Léger

Quoting Clement Leger (2021-09-13 01:26:33)

Quoted 8 lines

Currently, at91 pmc driver always register the syscore_ops whatever the status of the pmc node that has been found. When set as secure and disabled, the pmc should not be accessed or this will generate abort exceptions.
To avoid this, add a check on node availability before registering the syscore operations.

Any Fixes tag?

#4 lore raw
Quoted 11 lines · Stephen Boyd

Quoting Clement Leger (2021-09-13 01:26:33)

Quoted 8 lines

Currently, at91 pmc driver always register the syscore_ops whatever the status of the pmc node that has been found. When set as secure and disabled, the pmc should not be accessed or this will generate abort exceptions.
To avoid this, add a check on node availability before registering the syscore operations.

Any Fixes tag?

Since this was present from the start of the implementation, I think it should be the following:

Fixes b3b02eac33ed ("clk: at91: Add sama5d2 suspend/resume")
maintainer Applied
#5 lore raw
In reply to Clément Léger

Quoting Clément Léger (2021-09-13 01:26:33)

Quoted 9 lines

Currently, at91 pmc driver always register the syscore_ops whatever the status of the pmc node that has been found. When set as secure and disabled, the pmc should not be accessed or this will generate abort exceptions.
To avoid this, add a check on node availability before registering the syscore operations.

---

Applied to clk-next