Skip to content

Commit

Permalink
net: Trap attempts to call sock_kfree_s() with a NULL pointer.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David S. Miller committed Oct 14, 2014
1 parent dee49f2 commit e53da5f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1718,6 +1718,8 @@ EXPORT_SYMBOL(sock_kmalloc);
*/
void sock_kfree_s(struct sock *sk, void *mem, int size)
{
if (WARN_ON_ONCE(!mem))
return;
kfree(mem);
atomic_sub(size, &sk->sk_omem_alloc);
}
Expand Down

0 comments on commit e53da5f

Please sign in to comment.