Re: [PATCH net-next] net: sock: add the case if sk is NULL

From: Jakub Kicinski
Date: Fri Aug 06 2021 - 09:12:34 EST


On Fri, 6 Aug 2021 14:38:15 +0800 Yajun Deng wrote:
> Add the case if sk is NULL in sock_{put, hold},
> The caller is free to use it.
>
> Signed-off-by: Yajun Deng <yajun.deng@xxxxxxxxx>

The obvious complaint about this patch (and your previous netdev patch)
is that you're spraying branches everywhere in the code. Sure, it may
be okay for free(), given how expensive of an operation that is but
is having refcounting functions accept NULL really the best practice?

Can you give us examples in the kernel where that's the case?