netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bonding: return -ENOMEM on rlb_initialize() allocation failure
@ 2022-08-12  3:20 Jiapeng Chong
  2022-08-12  3:29 ` Jay Vosburgh
  2022-08-12  7:14 ` Christophe JAILLET
  0 siblings, 2 replies; 3+ messages in thread
From: Jiapeng Chong @ 2022-08-12  3:20 UTC (permalink / raw)
  To: j.vosburgh
  Cc: vfalico, andy, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, Jiapeng Chong, Abaci Robot

drivers/net/bonding/bond_alb.c:861 rlb_initialize() warn: returning -1 instead of -ENOMEM is sloppy.

Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=1896
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 drivers/net/bonding/bond_alb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 60cb9a0225aa..96cb4404b3c7 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -858,7 +858,7 @@ static int rlb_initialize(struct bonding *bond)
 
 	new_hashtbl = kmalloc(size, GFP_KERNEL);
 	if (!new_hashtbl)
-		return -1;
+		return -ENOMEM;
 
 	spin_lock_bh(&bond->mode_lock);
 
-- 
2.20.1.7.g153144c


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] bonding: return -ENOMEM on rlb_initialize() allocation failure
  2022-08-12  3:20 [PATCH] bonding: return -ENOMEM on rlb_initialize() allocation failure Jiapeng Chong
@ 2022-08-12  3:29 ` Jay Vosburgh
  2022-08-12  7:14 ` Christophe JAILLET
  1 sibling, 0 replies; 3+ messages in thread
From: Jay Vosburgh @ 2022-08-12  3:29 UTC (permalink / raw)
  To: Jiapeng Chong
  Cc: vfalico, andy, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, Abaci Robot

Jiapeng Chong <jiapeng.chong@linux.alibaba.com> wrote:

>drivers/net/bonding/bond_alb.c:861 rlb_initialize() warn: returning -1 instead of -ENOMEM is sloppy.

	I'll disagree; the return value is only ever tested for being
non-zero.

	-J

>Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=1896
>Reported-by: Abaci Robot <abaci@linux.alibaba.com>
>Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
>---
> drivers/net/bonding/bond_alb.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
>index 60cb9a0225aa..96cb4404b3c7 100644
>--- a/drivers/net/bonding/bond_alb.c
>+++ b/drivers/net/bonding/bond_alb.c
>@@ -858,7 +858,7 @@ static int rlb_initialize(struct bonding *bond)
> 
> 	new_hashtbl = kmalloc(size, GFP_KERNEL);
> 	if (!new_hashtbl)
>-		return -1;
>+		return -ENOMEM;
> 
> 	spin_lock_bh(&bond->mode_lock);
> 
>-- 
>2.20.1.7.g153144c
>

---
	-Jay Vosburgh, jay.vosburgh@canonical.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] bonding: return -ENOMEM on rlb_initialize() allocation failure
  2022-08-12  3:20 [PATCH] bonding: return -ENOMEM on rlb_initialize() allocation failure Jiapeng Chong
  2022-08-12  3:29 ` Jay Vosburgh
@ 2022-08-12  7:14 ` Christophe JAILLET
  1 sibling, 0 replies; 3+ messages in thread
From: Christophe JAILLET @ 2022-08-12  7:14 UTC (permalink / raw)
  To: Jiapeng Chong, j.vosburgh
  Cc: vfalico, andy, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, Abaci Robot

Le 12/08/2022 à 05:20, Jiapeng Chong a écrit :
> drivers/net/bonding/bond_alb.c:861 rlb_initialize() warn: returning -1 instead of -ENOMEM is sloppy.
> 
> Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=1896
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>   drivers/net/bonding/bond_alb.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
> index 60cb9a0225aa..96cb4404b3c7 100644
> --- a/drivers/net/bonding/bond_alb.c
> +++ b/drivers/net/bonding/bond_alb.c
> @@ -858,7 +858,7 @@ static int rlb_initialize(struct bonding *bond)
>   
>   	new_hashtbl = kmalloc(size, GFP_KERNEL);
>   	if (!new_hashtbl)
> -		return -1;
> +		return -ENOMEM;
>   
>   	spin_lock_bh(&bond->mode_lock);
>   

Hi,

Nit: if of any use, the only call chain leads to [1]:
bond_open()
--> bond_alb_initialize()
   --> rlb_initialize()

So, the error in bond_open() could be changed to ret instead of a hard 
coded -ENOMEM.

Just my 2c,


Other than that, for what it worth,
Reviewed-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

CJ

[1]: 
https://elixir.bootlin.com/linux/v5.19/source/drivers/net/bonding/bond_main.c#L4163

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-12  7:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-12  3:20 [PATCH] bonding: return -ENOMEM on rlb_initialize() allocation failure Jiapeng Chong
2022-08-12  3:29 ` Jay Vosburgh
2022-08-12  7:14 ` Christophe JAILLET

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).