All of lore.kernel.org
 help / color / mirror / Atom feed
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 3/5] mt76: fix a leaked reference by adding a missing of_node_put
Date: Fri, 22 Feb 2019 15:15:40 +0800	[thread overview]
Message-ID: <1550819742-32155-3-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_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


WARNING: multiple messages have this Message-ID (diff)
From: Wen Yang <wen.yang99@zte.com.cn>
To: linus.walleij@linaro.org
Cc: wang.yi59@zte.com.cn, andrew@lunn.ch,
	alexandre.belloni@bootlin.com, f.fainelli@gmail.com,
	michal.simek@xilinx.com, netdev@vger.kernel.org,
	linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	davem@davemloft.net, Wen Yang <wen.yang99@zte.com.cn>,
	matthias.bgg@gmail.com, linux-mediatek@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org, anirudh@xilinx.com,
	lorenzo.bianconi83@gmail.com, UNGLinuxDriver@microchip.com,
	John.Linn@xilinx.com, vivien.didelot@gmail.com,
	kvalo@codeaurora.org, nbd@nbd.name
Subject: [PATCH 3/5] mt76: fix a leaked reference by adding a missing of_node_put
Date: Fri, 22 Feb 2019 15:15:40 +0800	[thread overview]
Message-ID: <1550819742-32155-3-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_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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2019-02-22  7:16 UTC|newest]

Thread overview: 26+ 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
2019-02-22  7:15 ` [PATCH 2/5] net: mscc: ocelot: " Wen Yang
2019-02-22  7:15   ` Wen Yang
2019-02-22  7:15   ` 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-02-28  8:39     ` Kalle Valo
2019-02-28  8:39   ` Kalle Valo
2019-02-28  8:39     ` Kalle Valo
2019-04-05 13:15   ` Markus Elfring
2019-04-05 13:15     ` Markus Elfring
     [not found]     ` <799adbb0-23a6-bf20-f22d-4af68e9d0012-S0/GAf8tV78@public.gmane.org>
2019-04-08  6:55       ` [PATCH 3/5] mt76: fix a leaked reference by adding a missingof_node_put wen.yang99-Th6q7B73Y6EnDS1+zs4M5A
2019-04-08  7:37         ` Markus Elfring
2019-04-08  7:37           ` Markus Elfring
2019-02-22  7:15 ` [PATCH 4/5] net: xilinx: fix a leaked reference by adding missing of_node_put Wen Yang
2019-02-22  7:15   ` Wen Yang
2019-02-22  7:15   ` Wen Yang
2019-02-22  7:15 ` [PATCH 5/5] net: dsa: " Wen Yang
2019-02-22  7:15   ` Wen Yang
2019-02-24 20:32   ` David Miller
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
2019-02-22 10:38   ` Linus Walleij
2019-02-22 10:38   ` 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-3-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.