diff options
| author | Shang XiaoJing <shangxiaojing@huawei.com> | 2022-10-27 22:03:30 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-11-10 18:14:17 +0100 |
| commit | 9ae2c9a91ff068f4c3e392f47e8e26a1c9f85ebb (patch) | |
| tree | 0d513194a02f3d2427e3828ec3d24852129a428a /drivers/nfc | |
| parent | eecea068bf116d448c271263d879aa22926cc0d3 (diff) | |
| download | linux-9ae2c9a91ff068f4c3e392f47e8e26a1c9f85ebb.tar.gz linux-9ae2c9a91ff068f4c3e392f47e8e26a1c9f85ebb.tar.bz2 linux-9ae2c9a91ff068f4c3e392f47e8e26a1c9f85ebb.zip | |
nfc: nxp-nci: Fix potential memory leak in nxp_nci_send()
[ Upstream commit 7bf1ed6aff0f70434bd0cdd45495e83f1dffb551 ]
nxp_nci_send() will call nxp_nci_i2c_write(), and only free skb when
nxp_nci_i2c_write() failed. However, even if the nxp_nci_i2c_write()
run succeeds, the skb will not be freed in nxp_nci_i2c_write(). As the
result, the skb will memleak. nxp_nci_send() should also free the skb
when nxp_nci_i2c_write() succeeds.
Fixes: dece45855a8b ("NFC: nxp-nci: Add support for NXP NCI chips")
Signed-off-by: Shang XiaoJing <shangxiaojing@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/nfc')
| -rw-r--r-- | drivers/nfc/nxp-nci/core.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/nfc/nxp-nci/core.c b/drivers/nfc/nxp-nci/core.c index 2b0c7232e91f..b68b315689c3 100644 --- a/drivers/nfc/nxp-nci/core.c +++ b/drivers/nfc/nxp-nci/core.c @@ -77,10 +77,13 @@ static int nxp_nci_send(struct nci_dev *ndev, struct sk_buff *skb) return -EINVAL; r = info->phy_ops->write(info->phy_id, skb); - if (r < 0) + if (r < 0) { kfree_skb(skb); + return r; + } - return r; + consume_skb(skb); + return 0; } static struct nci_ops nxp_nci_ops = { |
