nfc: fix memory leak in llcp_sock_connect()
authorXiaoming Ni <nixiaoming@huawei.com>
Thu, 25 Mar 2021 03:51:12 +0000 (11:51 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 Apr 2021 09:59:06 +0000 (11:59 +0200)
commit83a09c10719661d8b51f1aa475ec52c13f3546d1
treee3874ab0a0c779e3ff8057f14853f633bf1c0527
parent013b8099064f2dc51e789e54a93edb65e2539792
nfc: fix memory leak in llcp_sock_connect()

commit 7574fcdbdcb335763b6b322f6928dc0fd5730451 upstream.

In llcp_sock_connect(), use kmemdup to allocate memory for
 "llcp_sock->service_name". The memory is not released in the sock_unlink
label of the subsequent failure branch.
As a result, memory leakage occurs.

fix CVE-2020-25672

Fixes: d646960f7986 ("NFC: Initial LLCP support")
Reported-by: "kiyin(尹亮)" <kiyin@tencent.com>
Link: https://www.openwall.com/lists/oss-security/2020/11/01/1
Cc: <stable@vger.kernel.org> #v3.3
Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/nfc/llcp_sock.c