diff options
author | Shang XiaoJing <shangxiaojing@huawei.com> | 2022-10-27 16:03:31 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2022-10-30 22:43:26 +0100 |
commit | 3a146b7e3099dc7cf3114f627d9b79291e2d2203 (patch) | |
tree | 28e335ba7e134ad15be2cc81c22be1891c08a041 /drivers/nfc/s3fwrn5 | |
parent | nfc: nxp-nci: Fix potential memory leak in nxp_nci_send() (diff) | |
download | linux-3a146b7e3099dc7cf3114f627d9b79291e2d2203.tar.xz linux-3a146b7e3099dc7cf3114f627d9b79291e2d2203.zip |
nfc: s3fwrn5: Fix potential memory leak in s3fwrn5_nci_send()
s3fwrn5_nci_send() will call s3fwrn5_i2c_write() or s3fwrn82_uart_write(),
and free the skb if write() failed. However, even if the write() run
succeeds, the skb will not be freed in write(). As the result, the skb
will memleak. s3fwrn5_nci_send() should also free the skb when write()
succeeds.
Fixes: c04c674fadeb ("nfc: s3fwrn5: Add driver for Samsung S3FWRN5 NFC Chip")
Signed-off-by: Shang XiaoJing <shangxiaojing@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/nfc/s3fwrn5')
-rw-r--r-- | drivers/nfc/s3fwrn5/core.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/nfc/s3fwrn5/core.c b/drivers/nfc/s3fwrn5/core.c index 1c412007fabb..0270e05b68df 100644 --- a/drivers/nfc/s3fwrn5/core.c +++ b/drivers/nfc/s3fwrn5/core.c @@ -110,11 +110,15 @@ static int s3fwrn5_nci_send(struct nci_dev *ndev, struct sk_buff *skb) } ret = s3fwrn5_write(info, skb); - if (ret < 0) + if (ret < 0) { kfree_skb(skb); + mutex_unlock(&info->mutex); + return ret; + } + consume_skb(skb); mutex_unlock(&info->mutex); - return ret; + return 0; } static int s3fwrn5_nci_post_setup(struct nci_dev *ndev) |