Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e53da5fb authored by David S. Miller's avatar David S. Miller
Browse files

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: default avatarDavid S. Miller <davem@davemloft.net>
parent dee49f20
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -1718,6 +1718,8 @@ EXPORT_SYMBOL(sock_kmalloc);
 */
 */
void sock_kfree_s(struct sock *sk, void *mem, int size)
void sock_kfree_s(struct sock *sk, void *mem, int size)
{
{
	if (WARN_ON_ONCE(!mem))
		return;
	kfree(mem);
	kfree(mem);
	atomic_sub(size, &sk->sk_omem_alloc);
	atomic_sub(size, &sk->sk_omem_alloc);
}
}