[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221117113714.12776-2-shangxiaojing@huawei.com>
Date: Thu, 17 Nov 2022 19:37:12 +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 1/3] nfc: nfcmrvl: Fix potential memory leak in nfcmrvl_i2c_nci_send()
nfcmrvl_i2c_nci_send() will be called by nfcmrvl_nci_send(), and skb
should be freed in nfcmrvl_i2c_nci_send(). However, nfcmrvl_nci_send()
won't free the skb when it failed for the test_bit(). Free the skb when
test_bit() failed.
Fixes: b5b3e23e4cac ("NFC: nfcmrvl: add i2c driver")
Signed-off-by: Shang XiaoJing <shangxiaojing@...wei.com>
Suggested-by: Pavel Machek <pavel@...x.de>
---
drivers/nfc/nfcmrvl/i2c.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/nfc/nfcmrvl/i2c.c b/drivers/nfc/nfcmrvl/i2c.c
index 24436c9e54c9..97600826af69 100644
--- a/drivers/nfc/nfcmrvl/i2c.c
+++ b/drivers/nfc/nfcmrvl/i2c.c
@@ -112,8 +112,10 @@ static int nfcmrvl_i2c_nci_send(struct nfcmrvl_private *priv,
struct nfcmrvl_i2c_drv_data *drv_data = priv->drv_data;
int ret;
- if (test_bit(NFCMRVL_PHY_ERROR, &priv->flags))
+ if (test_bit(NFCMRVL_PHY_ERROR, &priv->flags)) {
+ kfree_skb(skb);
return -EREMOTEIO;
+ }
ret = i2c_master_send(drv_data->i2c, skb->data, skb->len);
--
2.17.1
Powered by blists - more mailing lists