From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1322C19F2D for ; Fri, 12 Aug 2022 07:14:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237153AbiHLHOq (ORCPT ); Fri, 12 Aug 2022 03:14:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237127AbiHLHOn (ORCPT ); Fri, 12 Aug 2022 03:14:43 -0400 Received: from smtp.smtpout.orange.fr (smtp-16.smtpout.orange.fr [80.12.242.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4105531DEA for ; Fri, 12 Aug 2022 00:14:39 -0700 (PDT) Received: from [192.168.1.18] ([90.11.190.129]) by smtp.orange.fr with ESMTPA id MOsNovEvhsfCIMOsNocAyy; Fri, 12 Aug 2022 09:14:37 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 12 Aug 2022 09:14:37 +0200 X-ME-IP: 90.11.190.129 Message-ID: <7c3dda38-d741-8f5e-a034-b4678ed79fc0@wanadoo.fr> Date: Fri, 12 Aug 2022 09:14:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] bonding: return -ENOMEM on rlb_initialize() allocation failure Content-Language: en-US To: Jiapeng Chong , j.vosburgh@gmail.com Cc: vfalico@gmail.com, andy@greyhouse.net, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Abaci Robot References: <20220812032059.64572-1-jiapeng.chong@linux.alibaba.com> From: Christophe JAILLET In-Reply-To: <20220812032059.64572-1-jiapeng.chong@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Signed-off-by: Jiapeng Chong > --- > 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 CJ [1]: https://elixir.bootlin.com/linux/v5.19/source/drivers/net/bonding/bond_main.c#L4163