diff mbox series

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

Message ID 20210204072657.17554-1-zhengyongjun3@huawei.com
State New
Headers show
Series [net-next] net: ipv4: Return the correct errno code | expand

Commit Message

Zheng Yongjun Feb. 4, 2021, 7:26 a.m. UTC
When kalloc or kmemdup failed, should return ENOMEM rather than ENOBUF.

Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
 net/ipv4/devinet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jakub Kicinski Feb. 6, 2021, 7:19 p.m. UTC | #1
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@huawei.com>

> ---

>  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,
diff mbox series

Patch

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;
 }
 
 static void __devinet_sysctl_unregister(struct net *net,