Re: [PATCH 05/10] drivers:net: return -ENOMEM on allocation failure.
From: Allen
Date: Wed Sep 20 2017 - 03:11:11 EST
>
> 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);
}