]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net:nfc:digital: Fix a double free in digital_tg_recv_dep_req
authorLv Yunlong <lyl2019@mail.ustc.edu.cn>
Tue, 27 Apr 2021 16:22:58 +0000 (09:22 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 May 2021 07:44:32 +0000 (09:44 +0200)
[ 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>
net/nfc/digital_dep.c

index 65aaa9d7c8133c647c9c976d7981afb4c8b07744..bcd4d74e8a825d79df35fc1a697eb35361ed42f5 100644 (file)
@@ -1276,6 +1276,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);