net: Fix potential memory leak in proto_register()
commit02618095ab45aa6797d6ffb8396a131ada7f8a86
authorMiaohe Lin <linmiaohe@huawei.com>
Mon, 10 Aug 2020 12:16:58 +0000 (10 08:16 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Aug 2020 06:16:22 +0000 (19 08:16 +0200)
tree6da721083e1aefe12900f847d69b99d80c97a04a
parentf6c5d9f3361af1e28cd1337e8b94c8e0adee05dc
net: Fix potential memory leak in proto_register()

[ Upstream commit 0f5907af39137f8183ed536aaa00f322d7365130 ]

If we failed to assign proto idx, we free the twsk_slab_name but forget to
free the twsk_slab. Add a helper function tw_prot_cleanup() to free these
together and also use this helper function in proto_unregister().

Fixes: b45ce32135d1 ("sock: fix potential memory leak in proto_register()")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/core/sock.c