Skip to content

Commit b506bc9

Browse files
Dust Lidavem330
authored andcommitted
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: 6670e15 ("tcp: Namespace-ify sysctl_tcp_default_congestion_control") Signed-off-by: Dust Li <dust.li@linux.alibaba.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7ff0b60 commit b506bc9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/ipv4/tcp_ipv4.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2578,7 +2578,8 @@ static void __net_exit tcp_sk_exit(struct net *net)
25782578
{
25792579
int cpu;
25802580

2581-
module_put(net->ipv4.tcp_congestion_control->owner);
2581+
if (net->ipv4.tcp_congestion_control)
2582+
module_put(net->ipv4.tcp_congestion_control->owner);
25822583

25832584
for_each_possible_cpu(cpu)
25842585
inet_ctl_sock_destroy(*per_cpu_ptr(net->ipv4.tcp_sk, cpu));

0 commit comments

Comments
 (0)