linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net:nfc:digital: Fix a double free in digital_tg_recv_dep_req
@ 2021-04-27 16:22 Lv Yunlong
  2021-04-27 22:40 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Lv Yunlong @ 2021-04-27 16:22 UTC (permalink / raw)
  To: davem, kuba; +Cc: netdev, linux-kernel, Lv Yunlong

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>
---
 net/nfc/digital_dep.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/nfc/digital_dep.c b/net/nfc/digital_dep.c
index 5971fb6f51cc..dc21b4141b0a 100644
--- a/net/nfc/digital_dep.c
+++ b/net/nfc/digital_dep.c
@@ -1273,6 +1273,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);
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net:nfc:digital: Fix a double free in digital_tg_recv_dep_req
  2021-04-27 16:22 [PATCH] net:nfc:digital: Fix a double free in digital_tg_recv_dep_req Lv Yunlong
@ 2021-04-27 22:40 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-04-27 22:40 UTC (permalink / raw)
  To: Lv Yunlong; +Cc: davem, kuba, netdev, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Tue, 27 Apr 2021 09:22:58 -0700 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - net:nfc:digital: Fix a double free in digital_tg_recv_dep_req
    https://git.kernel.org/netdev/net-next/c/75258586793e

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-27 22:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-27 16:22 [PATCH] net:nfc:digital: Fix a double free in digital_tg_recv_dep_req Lv Yunlong
2021-04-27 22:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).