diff mbox series

[net-next] net: dsa: add missing of_node_put

Message ID 20190222111818.3888-1-himadri18.07@gmail.com
State Changes Requested
Delegated to: David Miller
Headers show
Series [net-next] net: dsa: add missing of_node_put | expand

Commit Message

Himadri Pandya Feb. 22, 2019, 11:18 a.m. UTC
Decrement the reference count on port while returning out of the
loop. Issue identified by Coccinelle.

Signed-off-by: Himadri Pandya <himadri18.07@gmail.com>
---
 net/dsa/dsa2.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Comments

Andrew Lunn Feb. 22, 2019, 2:36 p.m. UTC | #1
On Fri, Feb 22, 2019 at 04:48:18PM +0530, Himadri Pandya wrote:
> Decrement the reference count on port while returning out of the
> loop. Issue identified by Coccinelle.

You and Wen Yang are both fixing the same issue. Maybe you can
coordinate?

	Andrew
Himadri Pandya Feb. 23, 2019, 5:53 a.m. UTC | #2
On 22/02/19 8:06 PM, Andrew Lunn wrote:
> On Fri, Feb 22, 2019 at 04:48:18PM +0530, Himadri Pandya wrote:
>> Decrement the reference count on port while returning out of the
>> loop. Issue identified by Coccinelle.
> You and Wen Yang are both fixing the same issue. Maybe you can
> coordinate?

Sure.

- Himadri


>
> 	Andrew
diff mbox series

Patch

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index a1917025e155..396e7433dd8f 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -624,19 +624,25 @@  static int dsa_switch_parse_ports_of(struct dsa_switch *ds,
 	for_each_available_child_of_node(ports, port) {
 		err = of_property_read_u32(port, "reg", &reg);
 		if (err)
-			return err;
+			goto put_port;
 
-		if (reg >= ds->num_ports)
-			return -EINVAL;
+		if (reg >= ds->num_ports) {
+			err = -EINVAL;
+			goto put_port;
+		}
 
 		dp = &ds->ports[reg];
 
 		err = dsa_port_parse_of(dp, port);
 		if (err)
-			return err;
+			goto put_port;
 	}
 
 	return 0;
+
+put_port:
+	of_node_put(port);
+	return err;
 }
 
 static int dsa_switch_parse_member_of(struct dsa_switch *ds,