[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221027140332.18336-2-shangxiaojing@huawei.com>
Date: Thu, 27 Oct 2022 22:03:29 +0800
From: Shang XiaoJing <shangxiaojing@...wei.com>
To: <krzysztof.kozlowski@...aro.org>,
<sebastian.reichel@...labora.com>, <peda@...ntia.se>,
<khalasa@...p.pl>, <kuba@...nel.org>,
<u.kleine-koenig@...gutronix.de>, <michael@...le.cc>,
<sameo@...ux.intel.com>, <robert.dolca@...el.com>,
<clement.perrochaud@....com>, <r.baldyga@...sung.com>,
<cuissard@...vell.com>, <netdev@...r.kernel.org>
CC: <shangxiaojing@...wei.com>
Subject: [PATCH 1/4] nfc: fdp: Fix potential memory leak in fdp_nci_send()
fdp_nci_send() will call fdp_nci_i2c_write that will not free skb in
the function. As a result, when fdp_nci_i2c_write() finished, the skb
will memleak. fdp_nci_send() should free skb after fdp_nci_i2c_write()
finished.
Fixes: a06347c04c13 ("NFC: Add Intel Fields Peak NFC solution driver")
Signed-off-by: Shang XiaoJing <shangxiaojing@...wei.com>
---
drivers/nfc/fdp/fdp.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/nfc/fdp/fdp.c b/drivers/nfc/fdp/fdp.c
index c6b3334f24c9..f12f903a9dd1 100644
--- a/drivers/nfc/fdp/fdp.c
+++ b/drivers/nfc/fdp/fdp.c
@@ -249,11 +249,19 @@ static int fdp_nci_close(struct nci_dev *ndev)
static int fdp_nci_send(struct nci_dev *ndev, struct sk_buff *skb)
{
struct fdp_nci_info *info = nci_get_drvdata(ndev);
+ int ret;
if (atomic_dec_and_test(&info->data_pkt_counter))
info->data_pkt_counter_cb(ndev);
- return info->phy_ops->write(info->phy, skb);
+ ret = info->phy_ops->write(info->phy, skb);
+ if (ret < 0) {
+ kfree_skb(skb);
+ return ret;
+ }
+
+ consume_skb(skb);
+ return 0;
}
static int fdp_nci_request_firmware(struct nci_dev *ndev)
--
2.17.1
Powered by blists - more mailing lists