Skip to content

Commit e53da5f

Browse files
committed
net: Trap attempts to call sock_kfree_s() with a NULL pointer.
Unlike normal kfree() it is never right to call sock_kfree_s() with a NULL pointer, because sock_kfree_s() also has the side effect of discharging the memory from the sockets quota. Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent dee49f2 commit e53da5f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

net/core/sock.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,8 @@ EXPORT_SYMBOL(sock_kmalloc);
17181718
*/
17191719
void sock_kfree_s(struct sock *sk, void *mem, int size)
17201720
{
1721+
if (WARN_ON_ONCE(!mem))
1722+
return;
17211723
kfree(mem);
17221724
atomic_sub(size, &sk->sk_omem_alloc);
17231725
}

0 commit comments

Comments
 (0)