diff options
author | Lv Yunlong <lyl2019@mail.ustc.edu.cn> | 2021-04-27 19:22:58 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-05-22 11:57:34 +0300 |
commit | ff8fa09d0766f36864372948df791fa76782df9d (patch) | |
tree | b87e16528d6c26e50a861eea98eeff68b1639fe9 | |
parent | dc1b438a35773d030be0ee80d9c635c3e558a322 (diff) | |
download | linux-ff8fa09d0766f36864372948df791fa76782df9d.tar.xz |
net:nfc:digital: Fix a double free in digital_tg_recv_dep_req
[ Upstream commit 75258586793efc521e5dd52a5bf6c7a4cf7002be ]
In digital_tg_recv_dep_req, it calls nfc_tm_data_received(..,resp).
If nfc_tm_data_received() failed, the callee will free the resp via
kfree_skb() and return error. But in the exit branch, the resp
will be freed again.
My patch sets resp to NULL if nfc_tm_data_received() failed, to
avoid the double free.
Fixes: 1c7a4c24fbfd9 ("NFC Digital: Add target NFC-DEP support")
Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | net/nfc/digital_dep.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/net/nfc/digital_dep.c b/net/nfc/digital_dep.c index 4f9a973988b2..1eed0cf59190 100644 --- a/net/nfc/digital_dep.c +++ b/net/nfc/digital_dep.c @@ -1285,6 +1285,8 @@ static void digital_tg_recv_dep_req(struct nfc_digital_dev *ddev, void *arg, } rc = nfc_tm_data_received(ddev->nfc_dev, resp); + if (rc) + resp = NULL; exit: kfree_skb(ddev->chaining_skb); |