[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221117113714.12776-3-shangxiaojing@huawei.com>
Date: Thu, 17 Nov 2022 19:37:13 +0800
From: Shang XiaoJing <shangxiaojing@...wei.com>
To: <krzysztof.kozlowski@...aro.org>, <pavel@...x.de>,
<u.kleine-koenig@...gutronix.de>, <kuba@...nel.org>,
<michael@...le.cc>, <cuissard@...vell.com>,
<sameo@...ux.intel.com>, <clement.perrochaud@....com>,
<r.baldyga@...sung.com>, <netdev@...r.kernel.org>
CC: <shangxiaojing@...wei.com>
Subject: [PATCH 2/3] nfc: nxp-nci: Fix potential memory leak in nxp_nci_send()
nxp_nci_send() won't free the skb when it failed for the check before
write(). As the result, the skb will memleak. Free the skb when the
check failed.
Fixes: dece45855a8b ("NFC: nxp-nci: Add support for NXP NCI chips")
Signed-off-by: Shang XiaoJing <shangxiaojing@...wei.com>
Suggested-by: Pavel Machek <pavel@...x.de>
---
drivers/nfc/nxp-nci/core.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/nfc/nxp-nci/core.c b/drivers/nfc/nxp-nci/core.c
index 580cb6ecffee..66b198663387 100644
--- a/drivers/nfc/nxp-nci/core.c
+++ b/drivers/nfc/nxp-nci/core.c
@@ -73,11 +73,15 @@ static int nxp_nci_send(struct nci_dev *ndev, struct sk_buff *skb)
struct nxp_nci_info *info = nci_get_drvdata(ndev);
int r;
- if (!info->phy_ops->write)
+ if (!info->phy_ops->write) {
+ kfree_skb(skb);
return -EOPNOTSUPP;
+ }
- if (info->mode != NXP_NCI_MODE_NCI)
+ if (info->mode != NXP_NCI_MODE_NCI) {
+ kfree_skb(skb);
return -EINVAL;
+ }
r = info->phy_ops->write(info->phy_id, skb);
if (r < 0) {
--
2.17.1
Powered by blists - more mailing lists