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: dece45855a ("NFC: nxp-nci: Add support for NXP NCI chips")
Signed-off-by: Shang XiaoJing <shangxiaojing@huawei.com>
Suggested-by: Pavel Machek <pavel@denx.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Shang XiaoJing 2022-11-17 19:37:13 +08:00 committed by David S. Miller
parent e204ead354
commit 614761e111
1 changed files with 6 additions and 2 deletions

View File

@ -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); struct nxp_nci_info *info = nci_get_drvdata(ndev);
int r; int r;
if (!info->phy_ops->write) if (!info->phy_ops->write) {
kfree_skb(skb);
return -EOPNOTSUPP; return -EOPNOTSUPP;
}
if (info->mode != NXP_NCI_MODE_NCI) if (info->mode != NXP_NCI_MODE_NCI) {
kfree_skb(skb);
return -EINVAL; return -EINVAL;
}
r = info->phy_ops->write(info->phy_id, skb); r = info->phy_ops->write(info->phy_id, skb);
if (r < 0) { if (r < 0) {