From: Wen Yang <wen.yang99@zte.com.cn>
To: linus.walleij@linaro.org
Cc: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com,
davem@davemloft.net, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, alexandre.belloni@bootlin.com,
UNGLinuxDriver@microchip.com, nbd@nbd.name,
lorenzo.bianconi83@gmail.com, kvalo@codeaurora.org,
matthias.bgg@gmail.com, linux-wireless@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, anirudh@xilinx.com,
John.Linn@xilinx.com, michal.simek@xilinx.com,
wang.yi59@zte.com.cn, Wen Yang <wen.yang99@zte.com.cn>
Subject: [PATCH 2/5] net: mscc: ocelot: fix a leaked reference by adding a missing of_node_put
Date: Fri, 22 Feb 2019 15:15:39 +0800 [thread overview]
Message-ID: <1550819742-32155-2-git-send-email-wen.yang99@zte.com.cn> (raw)
In-Reply-To: <1550819742-32155-1-git-send-email-wen.yang99@zte.com.cn>
The call to of_parse_phandle returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.
Detected by coccinelle with the following warnings:
./drivers/net/ethernet/mscc/ocelot_board.c:293:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 249, but without a corresponding object release within this function.
./drivers/net/ethernet/mscc/ocelot_board.c:312:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 249, but without a corresponding object release within this function.
./drivers/net/ethernet/mscc/ocelot_board.c:336:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 249, but without a corresponding object release within this function.
./drivers/net/ethernet/mscc/ocelot_board.c:339:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 249, but without a corresponding object release within this function.
Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Microchip Linux Driver Support <UNGLinuxDriver@microchip.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
drivers/net/ethernet/mscc/ocelot_board.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mscc/ocelot_board.c b/drivers/net/ethernet/mscc/ocelot_board.c
index ca3ea2f..f1485a6 100644
--- a/drivers/net/ethernet/mscc/ocelot_board.c
+++ b/drivers/net/ethernet/mscc/ocelot_board.c
@@ -290,7 +290,7 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
err = ocelot_probe_port(ocelot, port, regs, phy);
if (err)
- return err;
+ goto err_probe_ports;
err = of_get_phy_mode(portnp);
if (err < 0)
@@ -309,7 +309,8 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
dev_err(ocelot->dev,
"invalid phy mode for port%d, (Q)SGMII only\n",
port);
- return -EINVAL;
+ err = -EINVAL;
+ goto err_probe_ports;
}
serdes = devm_of_phy_get(ocelot->dev, portnp, NULL);
@@ -328,6 +329,7 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
ocelot->ports[port]->serdes = serdes;
}
+ of_node_put(ports);
register_netdevice_notifier(&ocelot_netdevice_nb);
register_switchdev_blocking_notifier(&ocelot_switchdev_blocking_nb);
@@ -336,6 +338,7 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
return 0;
err_probe_ports:
+ of_node_put(ports);
return err;
}
--
2.9.5
next prev parent reply other threads:[~2019-02-22 7:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-22 7:15 [PATCH 1/5] net: dsa: fix a leaked reference by adding a missing of_node_put Wen Yang
2019-02-22 7:15 ` Wen Yang [this message]
2019-02-22 7:15 ` [PATCH 3/5] mt76: " Wen Yang
2019-02-28 8:39 ` Kalle Valo
2019-04-05 13:15 ` Markus Elfring
2019-02-22 7:15 ` [PATCH 4/5] net: xilinx: fix a leaked reference by adding " Wen Yang
2019-02-22 7:15 ` [PATCH 5/5] net: dsa: " Wen Yang
2019-02-24 20:32 ` David Miller
2019-02-22 10:38 ` [PATCH 1/5] net: dsa: fix a leaked reference by adding a " Linus Walleij
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=1550819742-32155-2-git-send-email-wen.yang99@zte.com.cn \
--to=wen.yang99@zte.com.cn \
--cc=John.Linn@xilinx.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andrew@lunn.ch \
--cc=anirudh@xilinx.com \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=kvalo@codeaurora.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo.bianconi83@gmail.com \
--cc=matthias.bgg@gmail.com \
--cc=michal.simek@xilinx.com \
--cc=nbd@nbd.name \
--cc=netdev@vger.kernel.org \
--cc=vivien.didelot@gmail.com \
--cc=wang.yi59@zte.com.cn \
/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).