From: Greg Kroah-Hartman <gregkh@linuxfoundation•org>
To: linux-kernel@vger•kernel.org
Cc: Sasha Levin <sashal@kernel•org>,
Greg Kroah-Hartman <gregkh@linuxfoundation•org>,
linux-wireless@vger•kernel.org, stable@vger•kernel.org,
"David S. Miller" <davem@davemloft•net>,
Matthias Brugger <matthias.bgg@gmail•com>,
linux-mediatek@lists•infradead.org,
linux-arm-kernel@lists•infradead.org, netdev@vger•kernel.org,
Lorenzo Bianconi <lorenzo.bianconi83@gmail•com>,
Wen Yang <wen.yang99@zte•com.cn>,
Kalle Valo <kvalo@codeaurora•org>, Felix Fietkau <nbd@nbd•name>
Subject: [PATCH 4.19 049/187] mt76: fix a leaked reference by adding a missing of_node_put
Date: Thu, 4 Apr 2019 10:46:26 +0200 [thread overview]
Message-ID: <20190404084605.380921548@linuxfoundation.org> (raw)
In-Reply-To: <20190404084603.119654039@linuxfoundation.org>
4.19-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 34e022d8b780a03902d82fb3997ba7c7b1f40c81 ]
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
Signed-off-by: Kalle Valo <kvalo@codeaurora•org>
Signed-off-by: Sasha Levin <sashal@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 530e5593765c..a1529920d877 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.19.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists•infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next parent reply other threads:[~2019-04-04 9:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190404084603.119654039@linuxfoundation.org>
2019-04-04 8:46 ` Greg Kroah-Hartman [this message]
2019-04-04 8:47 ` [PATCH 4.19 083/187] SoC: imx-sgtl5000: add missing put_device() Greg Kroah-Hartman
2019-04-04 8:47 ` [PATCH 4.19 124/187] perf/aux: Make perf_event accessible to setup_aux() Greg Kroah-Hartman
2019-04-04 8:48 ` [PATCH 4.19 162/187] cpu/hotplug: Mute hotplug lockdep during init Greg Kroah-Hartman
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=20190404084605.380921548@linuxfoundation.org \
--to=gregkh@linuxfoundation$(echo .)org \
--cc=davem@davemloft$(echo .)net \
--cc=kvalo@codeaurora$(echo .)org \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-mediatek@lists$(echo .)infradead.org \
--cc=linux-wireless@vger$(echo .)kernel.org \
--cc=lorenzo.bianconi83@gmail$(echo .)com \
--cc=matthias.bgg@gmail$(echo .)com \
--cc=nbd@nbd$(echo .)name \
--cc=netdev@vger$(echo .)kernel.org \
--cc=sashal@kernel$(echo .)org \
--cc=stable@vger$(echo .)kernel.org \
--cc=wen.yang99@zte$(echo .)com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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