summaryrefslogtreecommitdiffstats
path: root/drivers/nfc
diff options
context:
space:
mode:
authorShang XiaoJing <shangxiaojing@huawei.com>2022-10-27 22:03:32 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-11-10 18:15:28 +0100
commit5dfdac5e3f8db5f4445228c44f64091045644a3b (patch)
tree4d97ff41bea928853c76a7c696fd6384875250ad /drivers/nfc
parent7486f5c90078648de73d2544f51c64c8eac026bc (diff)
downloadlinux-stable-5dfdac5e3f8db5f4445228c44f64091045644a3b.tar.gz
linux-stable-5dfdac5e3f8db5f4445228c44f64091045644a3b.tar.bz2
linux-stable-5dfdac5e3f8db5f4445228c44f64091045644a3b.zip
nfc: nfcmrvl: Fix potential memory leak in nfcmrvl_i2c_nci_send()
[ Upstream commit 93d904a734a74c54d945a9884b4962977f1176cd ] 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@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/nfcmrvl/i2c.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/nfc/nfcmrvl/i2c.c b/drivers/nfc/nfcmrvl/i2c.c
index 01329b91d59d..a902720cd849 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,