From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751685AbdITHLG (ORCPT ); Wed, 20 Sep 2017 03:11:06 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:35875 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751000AbdITHLF (ORCPT ); Wed, 20 Sep 2017 03:11:05 -0400 X-Google-Smtp-Source: AOwi7QB7ONYGpyau/Kyb8Ga0exrwj+DVZefEIGJUxNK94c7GTY2bk35unowvGXlRu0bE4G0mkcakitd2A6VndCe2KR8= MIME-Version: 1.0 In-Reply-To: <20170913120909.GA11820@lunn.ch> References: <1505287939-14106-1-git-send-email-allen.lkml@gmail.com> <1505287939-14106-5-git-send-email-allen.lkml@gmail.com> <20170913120909.GA11820@lunn.ch> From: Allen Date: Wed, 20 Sep 2017 12:41:03 +0530 Message-ID: Subject: Re: [PATCH 05/10] drivers:net: return -ENOMEM on allocation failure. To: Andrew Lunn Cc: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > rlb_initialize() is only called by bond_alb_initialize(), and it > propagates the -1. That is only called by bond_open() with: > > if (bond_alb_initialize(bond, (BOND_MODE(bond) == BOND_MODE_ALB))) > return -ENOMEM; > Would this work? diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index c02cc81..89df377 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c @@ -864,7 +864,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); diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index c99dc59..edef242 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -3284,6 +3284,7 @@ static int bond_open(struct net_device *bond_dev) struct bonding *bond = netdev_priv(bond_dev); struct list_head *iter; struct slave *slave; + int ret; /* reset slave->backup and slave->inactive */ if (bond_has_slaves(bond)) { @@ -3303,8 +3304,9 @@ static int bond_open(struct net_device *bond_dev) /* bond_alb_initialize must be called before the timer * is started. */ - if (bond_alb_initialize(bond, (BOND_MODE(bond) == BOND_MODE_ALB))) - return -ENOMEM; + ret = bond_alb_initialize(bond, (BOND_MODE(bond) == BOND_MODE_ALB)); + if (ret) + return ret; if (bond->params.tlb_dynamic_lb) queue_delayed_work(bond->wq, &bond->alb_work, 0); }