Skip to content

Commit 3a146b7

Browse files
Shang XiaoJingdavem330
authored andcommitted
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: c04c674 ("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>
1 parent 7bf1ed6 commit 3a146b7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/nfc/s3fwrn5/core.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,15 @@ static int s3fwrn5_nci_send(struct nci_dev *ndev, struct sk_buff *skb)
110110
}
111111

112112
ret = s3fwrn5_write(info, skb);
113-
if (ret < 0)
113+
if (ret < 0) {
114114
kfree_skb(skb);
115+
mutex_unlock(&info->mutex);
116+
return ret;
117+
}
115118

119+
consume_skb(skb);
116120
mutex_unlock(&info->mutex);
117-
return ret;
121+
return 0;
118122
}
119123

120124
static int s3fwrn5_nci_post_setup(struct nci_dev *ndev)

0 commit comments

Comments
 (0)