Skip to contentSkip to conversation

PCI: rcar: Release temporary device tree node reference

PATCH Applied Yuho Choi 6 participants 6 messages Sep 24 – Nov 4

Subsystems (4)
lore
Share & tools
lore

Yuho Choi

author
#0 lore raw

PATCH v2 1/1 PCI: rcar: Release temporary device tree node reference

of_find_matching_node() returns a referenced node even when it is used only as a boolean test. Drop the reference right after the match check.

Fixes a115b1bd3af0 ("PCI: rcar: Add L1 link state fix into data abort hook")

---
Changes in v2:
- Use an explicit of_node_put() instead of __free(device_node) (Marek Vasut)
- Switch to my oss.patchbox address

v1: https://lore.kernel.org/all/[email protected]/

 drivers/pci/controller/pcie-rcar-host.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/pci/controller/pcie-rcar-host.c +5 -1
index cd9171eebc289..1f5e33c802b5b 100644
@@ -1122,7 +1122,11 @@ static const struct of_device_id rcar_pcie_abort_handler_of_match[] __initconst
 
 static int __init rcar_pcie_init(void)
 {
-	if (of_find_matching_node(NULL, rcar_pcie_abort_handler_of_match)) {
+	struct device_node *np;
+
+	np = of_find_matching_node(NULL, rcar_pcie_abort_handler_of_match);
+	if (np) {
+		of_node_put(np);
 #ifdef CONFIG_ARM_LPAE
 		hook_fault_code(17, rcar_pcie_aarch32_abort_handler, SIGBUS, 0,
 				"asynchronous external abort");

base-commit: f0100363d8c374bd8e9ea7c9ba02744f0b802ca4

Signature · 1 line
2.43.0
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines

of_find_matching_node() returns a referenced node even when it is used only as a boolean test. Drop the reference right after the match check.

Fixes a115b1bd3af0 ("PCI: rcar: Add L1 link state fix into data abort hook")

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Reviewed-by on v2 1/1
#2 lore raw
In reply to Yuho Choi
Quoted 9 lines · Yuho Choi

of_find_matching_node() returns a referenced node even when it is used only as a boolean test. Drop the reference right after the match check.

Fixes a115b1bd3af0 ("PCI: rcar: Add L1 link state fix into data abort hook")

---
Changes in v2:
- Use an explicit of_node_put() instead of __free(device_node) (Marek Vasut)
- Switch to my oss.patchbox address

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
maintainer Applied
#4 lore raw
In reply to Yuho Choi
Quoted 1 line · Yuho Choi

PCI: rcar: Release temporary device tree node reference

Applied, thanks!

[1/1] PCI: rcar: Release temporary device tree node reference

      commit: 186da40837a4a2472b8afbf7dbccbe1b1e0f16bf

Best regards,

Signature · 1 line
மணிவண்ணன் சதாசிவம்
#5 lore raw
In reply to Yuho Choi
Quoted 2 lines · Yuho Choi

of_find_matching_node() returns a referenced node even when it is used only as a boolean test. Drop the reference right after the match check.

I guess this actually fixes an of_node reference leak, right?

Quoted 34 lines
Fixes a115b1bd3af0 ("PCI: rcar: Add L1 link state fix into data abort hook")

---
Changes in v2:
- Use an explicit of_node_put() instead of __free(device_node) (Marek Vasut)
- Switch to my oss.patchbox address

v1: https://lore.kernel.org/all/[email protected]/

 drivers/pci/controller/pcie-rcar-host.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/pci/controller/pcie-rcar-host.c +5 -1
index cd9171eebc289..1f5e33c802b5b 100644
@@ -1122,7 +1122,11 @@ static const struct of_device_id rcar_pcie_abort_handler_of_match[] __initconst
 
 static int __init rcar_pcie_init(void)
 {
-	if (of_find_matching_node(NULL, rcar_pcie_abort_handler_of_match)) {
+	struct device_node *np;
+
+	np = of_find_matching_node(NULL, rcar_pcie_abort_handler_of_match);
+	if (np) {
+		of_node_put(np);
 #ifdef CONFIG_ARM_LPAE
 		hook_fault_code(17, rcar_pcie_aarch32_abort_handler, SIGBUS, 0,
 				"asynchronous external abort");

base-commit: f0100363d8c374bd8e9ea7c9ba02744f0b802ca4

Signature · 1 line
2.43.0