[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221027140332.18336-5-shangxiaojing@huawei.com>
Date: Thu, 27 Oct 2022 22:03:32 +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 4/4] 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()
will only free skb when i2c_master_send() return >=0, which means skb
will memleak when i2c_master_send() failed. Free skb no matter whether
i2c_master_send() succeeds.
Fixes: b5b3e23e4cac ("NFC: nfcmrvl: add i2c driver")
Signed-off-by: Shang XiaoJing <shangxiaojing@...wei.com>
---
drivers/nfc/nfcmrvl/i2c.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/nfc/nfcmrvl/i2c.c b/drivers/nfc/nfcmrvl/i2c.c
index acef0cfd76af..24436c9e54c9 100644
--- a/drivers/nfc/nfcmrvl/i2c.c
+++ b/drivers/nfc/nfcmrvl/i2c.c
@@ -132,10 +132,15 @@ static int nfcmrvl_i2c_nci_send(struct nfcmrvl_private *priv,
ret = -EREMOTEIO;
} else
ret = 0;
+ }
+
+ if (ret) {
kfree_skb(skb);
+ return ret;
}
- return ret;
+ consume_skb(skb);
+ return 0;
}
static void nfcmrvl_i2c_nci_update_config(struct nfcmrvl_private *priv,
--
2.17.1
Powered by blists - more mailing lists