Skip to content

Commit 7bf1ed6

Browse files
Shang XiaoJingdavem330
authored andcommitted
nfc: nxp-nci: Fix potential memory leak in nxp_nci_send()
nxp_nci_send() will call nxp_nci_i2c_write(), and only free skb when nxp_nci_i2c_write() failed. However, even if the nxp_nci_i2c_write() run succeeds, the skb will not be freed in nxp_nci_i2c_write(). As the result, the skb will memleak. nxp_nci_send() should also free the skb when nxp_nci_i2c_write() succeeds. Fixes: dece458 ("NFC: nxp-nci: Add support for NXP NCI chips") Signed-off-by: Shang XiaoJing <shangxiaojing@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8e4aae6 commit 7bf1ed6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/nfc/nxp-nci/core.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,13 @@ static int nxp_nci_send(struct nci_dev *ndev, struct sk_buff *skb)
8080
return -EINVAL;
8181

8282
r = info->phy_ops->write(info->phy_id, skb);
83-
if (r < 0)
83+
if (r < 0) {
8484
kfree_skb(skb);
85+
return r;
86+
}
8587

86-
return r;
88+
consume_skb(skb);
89+
return 0;
8790
}
8891

8992
static int nxp_nci_rf_pll_unlocked_ntf(struct nci_dev *ndev,

0 commit comments

Comments
 (0)