Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7243e352 authored by Dust Li's avatar Dust Li Committed by Greg Kroah-Hartman
Browse files

tcp: fix a potential NULL pointer dereference in tcp_sk_exit



[ Upstream commit b506bc975f60f06e13e74adb35e708a23dc4e87c ]

 When tcp_sk_init() failed in inet_ctl_sock_create(),
 'net->ipv4.tcp_congestion_control' will be left
 uninitialized, but tcp_sk_exit() hasn't check for
 that.

 This patch add checking on 'net->ipv4.tcp_congestion_control'
 in tcp_sk_exit() to prevent NULL-ptr dereference.

Fixes: 6670e152 ("tcp: Namespace-ify sysctl_tcp_default_congestion_control")
Signed-off-by: default avatarDust Li <dust.li@linux.alibaba.com>
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 0e0afb06
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2490,6 +2490,7 @@ static void __net_exit tcp_sk_exit(struct net *net)
{
	int cpu;

	if (net->ipv4.tcp_congestion_control)
		module_put(net->ipv4.tcp_congestion_control->owner);

	for_each_possible_cpu(cpu)