diff options
author | David S. Miller <davem@davemloft.net> | 2014-10-15 01:02:37 +0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-10-15 01:02:37 +0400 |
commit | e53da5fbfc02586fe4506ed583069b8205f3e38d (patch) | |
tree | 1837e8406e630c05e7a045e3bdcf6c4e2cd5860e /net | |
parent | dee49f203a7feef5d00c416b7dc7e34a7caba8e1 (diff) | |
download | linux-e53da5fbfc02586fe4506ed583069b8205f3e38d.tar.xz |
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>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/sock.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index b4f3ea2fce60..15e0c67b1069 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -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); } |