linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] net: dsa: fix a leaked reference by adding a missing of_node_put
@ 2019-02-22  7:15 Wen Yang
  2019-02-22  7:15 ` [PATCH 2/5] net: mscc: ocelot: " Wen Yang
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Wen Yang @ 2019-02-22  7:15 UTC (permalink / raw)
  To: linus.walleij
  Cc: andrew, vivien.didelot, f.fainelli, davem, netdev, linux-kernel,
	alexandre.belloni, UNGLinuxDriver, nbd, lorenzo.bianconi83,
	kvalo, matthias.bgg, linux-wireless, linux-arm-kernel,
	linux-mediatek, anirudh, John.Linn, michal.simek, wang.yi59,
	Wen Yang

The call to of_get_child_by_name 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/dsa/rtl8366rb.c:510:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function.
./drivers/net/dsa/rtl8366rb.c:518:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function.
./drivers/net/dsa/rtl8366rb.c:540:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function.
./drivers/net/dsa/rtl8366rb.c:548:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function.
./drivers/net/dsa/rtl8366rb.c:556:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function.
./drivers/net/dsa/rtl8366rb.c:561:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Vivien Didelot <vivien.didelot@gmail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/net/dsa/rtl8366rb.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c
index a4d5049..f4b14b6 100644
--- a/drivers/net/dsa/rtl8366rb.c
+++ b/drivers/net/dsa/rtl8366rb.c
@@ -507,7 +507,8 @@ static int rtl8366rb_setup_cascaded_irq(struct realtek_smi *smi)
 	irq = of_irq_get(intc, 0);
 	if (irq <= 0) {
 		dev_err(smi->dev, "failed to get parent IRQ\n");
-		return irq ? irq : -EINVAL;
+		ret = irq ? irq : -EINVAL;
+		goto out_put_node;
 	}
 
 	/* This clears the IRQ status register */
@@ -515,7 +516,7 @@ static int rtl8366rb_setup_cascaded_irq(struct realtek_smi *smi)
 			  &val);
 	if (ret) {
 		dev_err(smi->dev, "can't read interrupt status\n");
-		return ret;
+		goto out_put_node;
 	}
 
 	/* Fetch IRQ edge information from the descriptor */
@@ -537,7 +538,7 @@ static int rtl8366rb_setup_cascaded_irq(struct realtek_smi *smi)
 				 val);
 	if (ret) {
 		dev_err(smi->dev, "could not configure IRQ polarity\n");
-		return ret;
+		goto out_put_node;
 	}
 
 	ret = devm_request_threaded_irq(smi->dev, irq, NULL,
@@ -545,7 +546,7 @@ static int rtl8366rb_setup_cascaded_irq(struct realtek_smi *smi)
 					"RTL8366RB", smi);
 	if (ret) {
 		dev_err(smi->dev, "unable to request irq: %d\n", ret);
-		return ret;
+		goto out_put_node;
 	}
 	smi->irqdomain = irq_domain_add_linear(intc,
 					       RTL8366RB_NUM_INTERRUPT,
@@ -553,12 +554,15 @@ static int rtl8366rb_setup_cascaded_irq(struct realtek_smi *smi)
 					       smi);
 	if (!smi->irqdomain) {
 		dev_err(smi->dev, "failed to create IRQ domain\n");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto out_put_node;
 	}
 	for (i = 0; i < smi->num_ports; i++)
 		irq_set_parent(irq_create_mapping(smi->irqdomain, i), irq);
 
-	return 0;
+out_put_node:
+	of_node_put(intc);
+	return ret;
 }
 
 static int rtl8366rb_set_addr(struct realtek_smi *smi)
-- 
2.9.5


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

* [PATCH 2/5] net: mscc: ocelot: fix a leaked reference by adding a missing of_node_put
  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
  2019-02-22  7:15 ` [PATCH 3/5] mt76: " Wen Yang
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Wen Yang @ 2019-02-22  7:15 UTC (permalink / raw)
  To: linus.walleij
  Cc: andrew, vivien.didelot, f.fainelli, davem, netdev, linux-kernel,
	alexandre.belloni, UNGLinuxDriver, nbd, lorenzo.bianconi83,
	kvalo, matthias.bgg, linux-wireless, linux-arm-kernel,
	linux-mediatek, anirudh, John.Linn, michal.simek, wang.yi59,
	Wen Yang

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


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

* [PATCH 3/5] mt76: fix a leaked reference by adding a missing of_node_put
  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 ` [PATCH 2/5] net: mscc: ocelot: " Wen Yang
@ 2019-02-22  7:15 ` 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
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 9+ messages in thread
From: Wen Yang @ 2019-02-22  7:15 UTC (permalink / raw)
  To: linus.walleij
  Cc: andrew, vivien.didelot, f.fainelli, davem, netdev, linux-kernel,
	alexandre.belloni, UNGLinuxDriver, nbd, lorenzo.bianconi83,
	kvalo, matthias.bgg, linux-wireless, linux-arm-kernel,
	linux-mediatek, anirudh, John.Linn, michal.simek, wang.yi59,
	Wen Yang

The call to of_find_node_by_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/wireless/mediatek/mt76/eeprom.c:58:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 48, but without a corresponding object release within this function.
./drivers/net/wireless/mediatek/mt76/eeprom.c:61:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 48, but without a corresponding object release within this function.
./drivers/net/wireless/mediatek/mt76/eeprom.c:67:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 48, but without a corresponding object release within this function.
./drivers/net/wireless/mediatek/mt76/eeprom.c:70:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 48, but without a corresponding object release within this function.
./drivers/net/wireless/mediatek/mt76/eeprom.c:72:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 48, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Felix Fietkau <nbd@nbd.name>
Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Cc: Kalle Valo <kvalo@codeaurora.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-mediatek@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/net/wireless/mediatek/mt76/eeprom.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c
index 530e559..a1529920d 100644
--- a/drivers/net/wireless/mediatek/mt76/eeprom.c
+++ b/drivers/net/wireless/mediatek/mt76/eeprom.c
@@ -54,22 +54,30 @@ mt76_get_of_eeprom(struct mt76_dev *dev, int len)
 		part = np->name;
 
 	mtd = get_mtd_device_nm(part);
-	if (IS_ERR(mtd))
-		return PTR_ERR(mtd);
+	if (IS_ERR(mtd)) {
+		ret =  PTR_ERR(mtd);
+		goto out_put_node;
+	}
 
-	if (size <= sizeof(*list))
-		return -EINVAL;
+	if (size <= sizeof(*list)) {
+		ret = -EINVAL;
+		goto out_put_node;
+	}
 
 	offset = be32_to_cpup(list);
 	ret = mtd_read(mtd, offset, len, &retlen, dev->eeprom.data);
 	put_mtd_device(mtd);
 	if (ret)
-		return ret;
+		goto out_put_node;
 
-	if (retlen < len)
-		return -EINVAL;
+	if (retlen < len) {
+		ret = -EINVAL;
+		goto out_put_node;
+	}
 
-	return 0;
+out_put_node:
+	of_node_put(np);
+	return ret;
 #else
 	return -ENOENT;
 #endif
-- 
2.9.5


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

* [PATCH 4/5] net: xilinx: fix a leaked reference by adding missing of_node_put
  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 ` [PATCH 2/5] net: mscc: ocelot: " Wen Yang
  2019-02-22  7:15 ` [PATCH 3/5] mt76: " Wen Yang
@ 2019-02-22  7:15 ` Wen Yang
  2019-02-22  7:15 ` [PATCH 5/5] net: dsa: " Wen Yang
  2019-02-22 10:38 ` [PATCH 1/5] net: dsa: fix a leaked reference by adding a " Linus Walleij
  4 siblings, 0 replies; 9+ messages in thread
From: Wen Yang @ 2019-02-22  7:15 UTC (permalink / raw)
  To: linus.walleij
  Cc: andrew, vivien.didelot, f.fainelli, davem, netdev, linux-kernel,
	alexandre.belloni, UNGLinuxDriver, nbd, lorenzo.bianconi83,
	kvalo, matthias.bgg, linux-wireless, linux-arm-kernel,
	linux-mediatek, anirudh, John.Linn, michal.simek, wang.yi59,
	Wen Yang

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 warning:
./drivers/net/ethernet/xilinx/xilinx_axienet_main.c:1624:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1569, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Anirudha Sarangi <anirudh@xilinx.com>
Cc: John Linn <John.Linn@xilinx.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Michal Simek <michal.simek@xilinx.com>
Cc: netdev@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index 0789d8a..8335390 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -1575,11 +1575,13 @@ static int axienet_probe(struct platform_device *pdev)
 	ret = of_address_to_resource(np, 0, &dmares);
 	if (ret) {
 		dev_err(&pdev->dev, "unable to get DMA resource\n");
+		of_node_put(np);
 		goto free_netdev;
 	}
 	lp->dma_regs = devm_ioremap_resource(&pdev->dev, &dmares);
 	if (IS_ERR(lp->dma_regs)) {
 		dev_err(&pdev->dev, "could not map DMA regs\n");
+		of_node_put(np);
 		ret = PTR_ERR(lp->dma_regs);
 		goto free_netdev;
 	}
-- 
2.9.5


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

* [PATCH 5/5] net: dsa: fix a leaked reference by adding missing of_node_put
  2019-02-22  7:15 [PATCH 1/5] net: dsa: fix a leaked reference by adding a missing of_node_put Wen Yang
                   ` (2 preceding siblings ...)
  2019-02-22  7:15 ` [PATCH 4/5] net: xilinx: fix a leaked reference by adding " Wen Yang
@ 2019-02-22  7:15 ` 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
  4 siblings, 1 reply; 9+ messages in thread
From: Wen Yang @ 2019-02-22  7:15 UTC (permalink / raw)
  To: linus.walleij
  Cc: andrew, vivien.didelot, f.fainelli, davem, netdev, linux-kernel,
	alexandre.belloni, UNGLinuxDriver, nbd, lorenzo.bianconi83,
	kvalo, matthias.bgg, linux-wireless, linux-arm-kernel,
	linux-mediatek, anirudh, John.Linn, michal.simek, wang.yi59,
	Wen Yang

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:
./net/dsa/port.c:294:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 284, but without a corresponding object release within this function.
./net/dsa/dsa2.c:627:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 618, but without a corresponding object release within this function.
./net/dsa/dsa2.c:630:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 618, but without a corresponding object release within this function.
./net/dsa/dsa2.c:636:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 618, but without a corresponding object release within this function.
./net/dsa/dsa2.c:639:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 618, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Vivien Didelot <vivien.didelot@gmail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 net/dsa/dsa2.c | 16 ++++++++++------
 net/dsa/port.c |  1 +
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 8c431e0..89823f0 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -613,7 +613,7 @@ static int dsa_switch_parse_ports_of(struct dsa_switch *ds,
 	struct device_node *ports, *port;
 	struct dsa_port *dp;
 	u32 reg;
-	int err;
+	int err = 0;
 
 	ports = of_get_child_by_name(dn, "ports");
 	if (!ports) {
@@ -624,19 +624,23 @@ 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 out_put_node;
 
-		if (reg >= ds->num_ports)
-			return -EINVAL;
+		if (reg >= ds->num_ports) {
+			err = -EINVAL;
+			goto out_put_node;
+		}
 
 		dp = &ds->ports[reg];
 
 		err = dsa_port_parse_of(dp, port);
 		if (err)
-			return err;
+			goto out_put_node;
 	}
 
-	return 0;
+out_put_node:
+	of_node_put(ports);
+	return err;
 }
 
 static int dsa_switch_parse_member_of(struct dsa_switch *ds,
diff --git a/net/dsa/port.c b/net/dsa/port.c
index 2d7e01b..a6d9a04 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -291,6 +291,7 @@ static struct phy_device *dsa_port_get_phy_device(struct dsa_port *dp)
 		return ERR_PTR(-EPROBE_DEFER);
 	}
 
+	of_node_put(phy_dn);
 	return phydev;
 }
 
-- 
2.9.5


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

* Re: [PATCH 1/5] net: dsa: fix a leaked reference by adding a missing of_node_put
  2019-02-22  7:15 [PATCH 1/5] net: dsa: fix a leaked reference by adding a missing of_node_put Wen Yang
                   ` (3 preceding siblings ...)
  2019-02-22  7:15 ` [PATCH 5/5] net: dsa: " Wen Yang
@ 2019-02-22 10:38 ` Linus Walleij
  4 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2019-02-22 10:38 UTC (permalink / raw)
  To: Wen Yang
  Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S. Miller,
	netdev, linux-kernel, Alexandre Belloni, UNGLinuxDriver,
	Felix Fietkau, Lorenzo Bianconi, Kalle Valo, Matthias Brugger,
	linux-wireless, Linux ARM,
	moderated list:ARM/Mediatek SoC support, anirudh, John Linn,
	Michal Simek, wang.yi59

On Fri, Feb 22, 2019 at 8:15 AM Wen Yang <wen.yang99@zte.com.cn> wrote:

> The call to of_get_child_by_name 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/dsa/rtl8366rb.c:510:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function.
> ./drivers/net/dsa/rtl8366rb.c:518:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function.
> ./drivers/net/dsa/rtl8366rb.c:540:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function.
> ./drivers/net/dsa/rtl8366rb.c:548:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function.
> ./drivers/net/dsa/rtl8366rb.c:556:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function.
> ./drivers/net/dsa/rtl8366rb.c:561:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function.
>
> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Vivien Didelot <vivien.didelot@gmail.com>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: netdev@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH 5/5] net: dsa: fix a leaked reference by adding missing of_node_put
  2019-02-22  7:15 ` [PATCH 5/5] net: dsa: " Wen Yang
@ 2019-02-24 20:32   ` David Miller
  0 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2019-02-24 20:32 UTC (permalink / raw)
  To: wen.yang99
  Cc: linus.walleij, andrew, vivien.didelot, f.fainelli, netdev,
	linux-kernel, alexandre.belloni, UNGLinuxDriver, nbd,
	lorenzo.bianconi83, kvalo, matthias.bgg, linux-wireless,
	linux-arm-kernel, linux-mediatek, anirudh, John.Linn,
	michal.simek, wang.yi59

From: Wen Yang <wen.yang99@zte.com.cn>
Date: Fri, 22 Feb 2019 15:15:42 +0800

> diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
> index 8c431e0..89823f0 100644
> --- a/net/dsa/dsa2.c
> +++ b/net/dsa/dsa2.c
> @@ -613,7 +613,7 @@ static int dsa_switch_parse_ports_of(struct dsa_switch *ds,
>  	struct device_node *ports, *port;
>  	struct dsa_port *dp;
>  	u32 reg;
> -	int err;
> +	int err = 0;

Please preserve the reverse christmas tree ordering of variables here.

Thank you.

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

* Re: [PATCH 3/5] mt76: fix a leaked reference by adding a missing of_node_put
  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
  1 sibling, 0 replies; 9+ messages in thread
From: Kalle Valo @ 2019-02-28  8:39 UTC (permalink / raw)
  To: Wen Yang
  Cc: linus.walleij, andrew, vivien.didelot, f.fainelli, davem, netdev,
	linux-kernel, alexandre.belloni, UNGLinuxDriver, nbd,
	lorenzo.bianconi83, matthias.bgg, linux-wireless,
	linux-arm-kernel, linux-mediatek, anirudh, John.Linn,
	michal.simek, wang.yi59, Wen Yang

Wen Yang <wen.yang99@zte.com.cn> wrote:

> The call to of_find_node_by_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/wireless/mediatek/mt76/eeprom.c:58:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 48, but without a corresponding object release within this function.
> ./drivers/net/wireless/mediatek/mt76/eeprom.c:61:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 48, but without a corresponding object release within this function.
> ./drivers/net/wireless/mediatek/mt76/eeprom.c:67:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 48, but without a corresponding object release within this function.
> ./drivers/net/wireless/mediatek/mt76/eeprom.c:70:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 48, but without a corresponding object release within this function.
> ./drivers/net/wireless/mediatek/mt76/eeprom.c:72:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 48, but without a corresponding object release within this function.
> 
> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
> Cc: Felix Fietkau <nbd@nbd.name>
> Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
> Cc: Kalle Valo <kvalo@codeaurora.org>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Matthias Brugger <matthias.bgg@gmail.com>
> Cc: linux-wireless@vger.kernel.org
> Cc: netdev@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-mediatek@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org

Patch applied to wireless-drivers-next.git, thanks.

34e022d8b780 mt76: fix a leaked reference by adding a missing of_node_put

-- 
https://patchwork.kernel.org/patch/10825315/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


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

* Re: [PATCH 3/5] mt76: fix a leaked reference by adding a missing of_node_put
  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
  1 sibling, 0 replies; 9+ messages in thread
From: Markus Elfring @ 2019-04-05 13:15 UTC (permalink / raw)
  To: Wen Yang, linux-arm-kernel, linux-mediatek, linux-wireless, netdev
  Cc: UNGLinuxDriver, Alexandre Belloni, Andrew Lunn, Anirudha Sarangi,
	David S. Miller, Florian Fainelli, Kalle Valo, Linus Walleij,
	Lorenzo Bianconi, Matthias Brugger, Michal Simek, Felix Fietkau,
	vivien.didelot, John Linn, Yi Wang, linux-kernel

> @@ -54,22 +54,30 @@  mt76_get_of_eeprom(struct mt76_dev *dev, int len)
>  		part = np->name;
>
>  	mtd = get_mtd_device_nm(part);
> +	if (retlen < len) {
> +		ret = -EINVAL;
> +		goto out_put_node;

I find a jump to an immediately following source code place unnecessary.
Would you like to delete it?


> +	}
>
> -	return 0;
> +out_put_node:
> +	of_node_put(np);
> +	return ret;
>  #else

Can another bit of fine-tuning matter here?
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/net/wireless/mediatek/mt76/eeprom.c?id=34e022d8b780a03902d82fb3997ba7c7b1f40c81#n73

Regards,
Markus

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

end of thread, other threads:[~2019-04-05 13:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 2/5] net: mscc: ocelot: " Wen Yang
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

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