Commit 614761e1 authored by Shang XiaoJing's avatar Shang XiaoJing Committed by David S. Miller

nfc: nxp-nci: Fix potential memory leak in nxp_nci_send()

nxp_nci_send() won't free the skb when it failed for the check before
write(). As the result, the skb will memleak. Free the skb when the
check failed.

Fixes: dece4585 ("NFC: nxp-nci: Add support for NXP NCI chips")
Signed-off-by: default avatarShang XiaoJing <shangxiaojing@huawei.com>
Suggested-by: default avatarPavel Machek <pavel@denx.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e204ead3
......@@ -73,11 +73,15 @@ static int nxp_nci_send(struct nci_dev *ndev, struct sk_buff *skb)
struct nxp_nci_info *info = nci_get_drvdata(ndev);
int r;
if (!info->phy_ops->write)
if (!info->phy_ops->write) {
kfree_skb(skb);
return -EOPNOTSUPP;
}
if (info->mode != NXP_NCI_MODE_NCI)
if (info->mode != NXP_NCI_MODE_NCI) {
kfree_skb(skb);
return -EINVAL;
}
r = info->phy_ops->write(info->phy_id, skb);
if (r < 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment