Skip to content

Commit 22a0e18

Browse files
edumazetdavem330
authored andcommitted
net: properly release sk_frag.page
I mistakenly added the code to release sk->sk_frag in sk_common_release() instead of sk_destruct() TCP sockets using sk->sk_allocation == GFP_ATOMIC do no call sk_common_release() at close time, thus leaking one (order-3) page. iSCSI is using such sockets. Fixes: 5640f76 ("net: use a per task frag allocator") Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 622c36f commit 22a0e18

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

net/core/sock.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,11 @@ static void __sk_destruct(struct rcu_head *head)
14421442
pr_debug("%s: optmem leakage (%d bytes) detected\n",
14431443
__func__, atomic_read(&sk->sk_omem_alloc));
14441444

1445+
if (sk->sk_frag.page) {
1446+
put_page(sk->sk_frag.page);
1447+
sk->sk_frag.page = NULL;
1448+
}
1449+
14451450
if (sk->sk_peer_cred)
14461451
put_cred(sk->sk_peer_cred);
14471452
put_pid(sk->sk_peer_pid);
@@ -2787,11 +2792,6 @@ void sk_common_release(struct sock *sk)
27872792

27882793
sk_refcnt_debug_release(sk);
27892794

2790-
if (sk->sk_frag.page) {
2791-
put_page(sk->sk_frag.page);
2792-
sk->sk_frag.page = NULL;
2793-
}
2794-
27952795
sock_put(sk);
27962796
}
27972797
EXPORT_SYMBOL(sk_common_release);

0 commit comments

Comments
 (0)