dccp: Fix possible memleak in dccp_init and dccp_fini
authorWang Hai <wanghai38@huawei.com>
Tue, 9 Jun 2020 14:18:16 +0000 (22:18 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Jun 2020 14:42:01 +0000 (16:42 +0200)
commit1e64ca668051910241499c44750011101b48ee30
tree3b5264b0b9d8ec0f963cb6b5d480f66a03ae2787
parentcf39fe5340fc377fa57f828403e56a746c7a0583
dccp: Fix possible memleak in dccp_init and dccp_fini

[ Upstream commit c96b6acc8f89a4a7f6258dfe1d077654c11415be ]

There are some memory leaks in dccp_init() and dccp_fini().

In dccp_fini() and the error handling path in dccp_init(), free lhash2
is missing. Add inet_hashinfo2_free_mod() to do it.

If inet_hashinfo2_init_mod() failed in dccp_init(),
percpu_counter_destroy() should be called to destroy dccp_orphan_count.
It need to goto out_free_percpu when inet_hashinfo2_init_mod() failed.

Fixes: c92c81df93df ("net: dccp: fix kernel crash on module load")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/net/inet_hashtables.h
net/dccp/proto.c