mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 12:57:53 +00:00
tcp: fix over estimation in sk_forced_mem_schedule()
commitc4ee118561
upstream. sk_forced_mem_schedule() has a bug similar to ones fixed in commit7c80b038d2
("net: fix sk_wmem_schedule() and sk_rmem_schedule() errors") While this bug has little chance to trigger in old kernels, we need to fix it before the following patch. Fixes:d83769a580
("tcp: fix possible deadlock in tcp_send_fin()") Signed-off-by: Eric Dumazet <edumazet@google.com> Acked-by: Soheil Hassas Yeganeh <soheil@google.com> Reviewed-by: Shakeel Butt <shakeelb@google.com> Reviewed-by: Wei Wang <weiwan@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
e832c26e7e
commit
0c083f0559
1 changed files with 4 additions and 3 deletions
|
@ -3367,11 +3367,12 @@ void tcp_xmit_retransmit_queue(struct sock *sk)
|
||||||
*/
|
*/
|
||||||
void sk_forced_mem_schedule(struct sock *sk, int size)
|
void sk_forced_mem_schedule(struct sock *sk, int size)
|
||||||
{
|
{
|
||||||
int amt;
|
int delta, amt;
|
||||||
|
|
||||||
if (size <= sk->sk_forward_alloc)
|
delta = size - sk->sk_forward_alloc;
|
||||||
|
if (delta <= 0)
|
||||||
return;
|
return;
|
||||||
amt = sk_mem_pages(size);
|
amt = sk_mem_pages(delta);
|
||||||
sk->sk_forward_alloc += amt * SK_MEM_QUANTUM;
|
sk->sk_forward_alloc += amt * SK_MEM_QUANTUM;
|
||||||
sk_memory_allocated_add(sk, amt);
|
sk_memory_allocated_add(sk, amt);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue