Skip to contentSkip to conversation

mips: cavium-octeon: Fix missing of_node_put() in octeon2_usb_clocks_start

PATCH Applied Liang He 2 participants 2 messages Jul 1, 2022 – Jul 5, 2022 MIPS

lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH 1/1 mips: cavium-octeon: Fix missing of_node_put() in octeon2_usb_clocks_start

We should call of_node_put() for the reference 'uctl_node' returned by of_get_parent() which will increase the refcount. Otherwise, there will be a refcount leak bug.

---
 arch/mips/cavium-octeon/octeon-platform.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/cavium-octeon/octeon-platform.c +2 -1
index a994022e32c9..ce05c0dd3acd 100644
@@ -86,11 +86,12 @@ static void octeon2_usb_clocks_start(struct device *dev)
 					 "refclk-frequency", &clock_rate);
 		if (i) {
 			dev_err(dev, "No UCTL \"refclk-frequency\"\n");
+			of_node_put(uctl_node);
 			goto exit;
 		}
 		i = of_property_read_string(uctl_node,
 					    "refclk-type", &clock_type);
-
+		of_node_put(uctl_node);
 		if (!i && strcmp("crystal", clock_type) == 0)
 			is_crystal_clock = true;
 	}
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 29 lines · Liang He

We should call of_node_put() for the reference 'uctl_node' returned by of_get_parent() which will increase the refcount. Otherwise, there will be a refcount leak bug.

---
 arch/mips/cavium-octeon/octeon-platform.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/cavium-octeon/octeon-platform.c +2 -1
index a994022e32c9..ce05c0dd3acd 100644
@@ -86,11 +86,12 @@ static void octeon2_usb_clocks_start(struct device *dev)
 					 "refclk-frequency", &clock_rate);
 		if (i) {
 			dev_err(dev, "No UCTL \"refclk-frequency\"\n");
+			of_node_put(uctl_node);
 			goto exit;
 		}
 		i = of_property_read_string(uctl_node,
 					    "refclk-type", &clock_type);
-
+		of_node_put(uctl_node);
 		if (!i && strcmp("crystal", clock_type) == 0)
 			is_crystal_clock = true;
 	}
Signature · 1 line
2.25.1

applied to mips-next.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]