netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: dsa: add missing of_node_put
@ 2019-02-22 11:18 Himadri Pandya
  2019-02-22 14:36 ` Andrew Lunn
  0 siblings, 1 reply; 3+ messages in thread
From: Himadri Pandya @ 2019-02-22 11:18 UTC (permalink / raw)
  To: andrew
  Cc: vivien.didelot, f.fainelli, davem, netdev, linux-kernel, Himadri Pandya

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(-)

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,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: dsa: add missing of_node_put
  2019-02-22 11:18 [PATCH net-next] net: dsa: add missing of_node_put Himadri Pandya
@ 2019-02-22 14:36 ` Andrew Lunn
  2019-02-23  5:53   ` Himadri Pandya
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Lunn @ 2019-02-22 14:36 UTC (permalink / raw)
  To: Himadri Pandya, wen.yang99
  Cc: vivien.didelot, f.fainelli, davem, netdev, linux-kernel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: dsa: add missing of_node_put
  2019-02-22 14:36 ` Andrew Lunn
@ 2019-02-23  5:53   ` Himadri Pandya
  0 siblings, 0 replies; 3+ messages in thread
From: Himadri Pandya @ 2019-02-23  5:53 UTC (permalink / raw)
  To: Andrew Lunn, wen.yang99
  Cc: vivien.didelot, f.fainelli, davem, netdev, linux-kernel


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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-23  5:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-22 11:18 [PATCH net-next] net: dsa: add missing of_node_put Himadri Pandya
2019-02-22 14:36 ` Andrew Lunn
2019-02-23  5:53   ` Himadri Pandya

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).