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

Commit b506bc97 authored by Dust Li's avatar Dust Li Committed by David S. Miller
Browse files

tcp: fix a potential NULL pointer dereference in tcp_sk_exit



 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>
parent 7ff0b608
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2578,6 +2578,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)