Commit 93d904a7 authored by Shang XiaoJing's avatar Shang XiaoJing Committed by David S. Miller

nfc: nfcmrvl: Fix potential memory leak in nfcmrvl_i2c_nci_send()

nfcmrvl_i2c_nci_send() will be called by nfcmrvl_nci_send(), and skb
should be freed in nfcmrvl_i2c_nci_send(). However, nfcmrvl_nci_send()
will only free skb when i2c_master_send() return >=0, which means skb
will memleak when i2c_master_send() failed. Free skb no matter whether
i2c_master_send() succeeds.

Fixes: b5b3e23e ("NFC: nfcmrvl: add i2c driver")
Signed-off-by: default avatarShang XiaoJing <shangxiaojing@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3a146b7e
...@@ -132,10 +132,15 @@ static int nfcmrvl_i2c_nci_send(struct nfcmrvl_private *priv, ...@@ -132,10 +132,15 @@ static int nfcmrvl_i2c_nci_send(struct nfcmrvl_private *priv,
ret = -EREMOTEIO; ret = -EREMOTEIO;
} else } else
ret = 0; ret = 0;
}
if (ret) {
kfree_skb(skb); kfree_skb(skb);
return ret;
} }
return ret; consume_skb(skb);
return 0;
} }
static void nfcmrvl_i2c_nci_update_config(struct nfcmrvl_private *priv, static void nfcmrvl_i2c_nci_update_config(struct nfcmrvl_private *priv,
......
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