From: Himadri Pandya <himadri18.07@gmail.com>
To: andrew@lunn.ch
Cc: vivien.didelot@gmail.com, f.fainelli@gmail.com,
davem@davemloft.net, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
Himadri Pandya <himadri18.07@gmail.com>
Subject: [PATCH net-next] net: dsa: add missing of_node_put
Date: Fri, 22 Feb 2019 16:48:18 +0530 [thread overview]
Message-ID: <20190222111818.3888-1-himadri18.07@gmail.com> (raw)
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", ®);
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
next reply other threads:[~2019-02-22 11:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-22 11:18 Himadri Pandya [this message]
2019-02-22 14:36 ` [PATCH net-next] net: dsa: add missing of_node_put Andrew Lunn
2019-02-23 5:53 ` Himadri Pandya
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190222111818.3888-1-himadri18.07@gmail.com \
--to=himadri18.07@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=vivien.didelot@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).