Commit e913fb27 authored by Pai's avatar Pai Committed by David S. Miller

net: Fix Kernel Panic in bonding driver debugfs file: rlb_hash_table

This patch fixes a Kernel Panic in bonding driver debugfs file: rlb_hash_table.

$> modprobe bonding mode=6
$> cat /sys/kernel/debug/bonding/bond0/rlb_hash_table

This will crash the kernel. The struct alb_bond_info is initialized only when
the bonding interface is initialized (ip link set bond0 up) and not at the time
it is allocated. If we try to read the table before that, it'll result in a
kernel panic.

The patch applies against both net and net-next
Signed-off-by: default avatarVishwanath Pai <vpai@akamai.com>
Signed-off-by: default avatarAndy Gospodarek <gospo@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 50d4964f
...@@ -4544,6 +4544,8 @@ unsigned int bond_get_num_tx_queues(void) ...@@ -4544,6 +4544,8 @@ unsigned int bond_get_num_tx_queues(void)
int bond_create(struct net *net, const char *name) int bond_create(struct net *net, const char *name)
{ {
struct net_device *bond_dev; struct net_device *bond_dev;
struct bonding *bond;
struct alb_bond_info *bond_info;
int res; int res;
rtnl_lock(); rtnl_lock();
...@@ -4557,6 +4559,14 @@ int bond_create(struct net *net, const char *name) ...@@ -4557,6 +4559,14 @@ int bond_create(struct net *net, const char *name)
return -ENOMEM; return -ENOMEM;
} }
/*
* Initialize rx_hashtbl_used_head to RLB_NULL_INDEX.
* It is set to 0 by default which is wrong.
*/
bond = netdev_priv(bond_dev);
bond_info = &(BOND_ALB_INFO(bond));
bond_info->rx_hashtbl_used_head = RLB_NULL_INDEX;
dev_net_set(bond_dev, net); dev_net_set(bond_dev, net);
bond_dev->rtnl_link_ops = &bond_link_ops; bond_dev->rtnl_link_ops = &bond_link_ops;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment