Re: [PATCH net-next] net: ipv4: Return the correct errno code

From: Jakub Kicinski
Date: Sat Feb 06 2021 - 14:20:57 EST


On Thu, 4 Feb 2021 15:26:57 +0800 Zheng Yongjun wrote:
> When kalloc or kmemdup failed, should return ENOMEM rather than ENOBUF.
>
> Signed-off-by: Zheng Yongjun <zhengyongjun3@xxxxxxxxxx>
> ---
> net/ipv4/devinet.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
> index 123a6d39438f..fa586e915621 100644
> --- a/net/ipv4/devinet.c
> +++ b/net/ipv4/devinet.c
> @@ -2582,7 +2582,7 @@ static int __devinet_sysctl_register(struct net *net, char *dev_name,
> free:
> kfree(t);
> out:
> - return -ENOBUFS;
> + return -ENOMEM;

But this path also gets hit when registration fails.
Are you sure registration also only fails when there is no memory?

> }
>
> static void __devinet_sysctl_unregister(struct net *net,