[PATCH] bonding: fix an oops when slave device does not provide get_stats

Bonding driver unconditionnaly dereference get_stats function pointer
for each of its slave device. This patch
- adds a check for NULL dev->get_stats pointer in bond_get_stats
- prints a notice when the bonding device enslave a device without
  get_stats function.

Signed-off-by: Laurent Riffard <laurent.riffard@free.fr>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
This commit is contained in:
Laurent Riffard 2006-11-18 12:03:04 +01:00 коммит произвёл Jeff Garzik
Родитель c1cb0b77f9
Коммит 418e8f3d7e
1 изменённых файлов: 31 добавлений и 22 удалений

Просмотреть файл

@ -1336,6 +1336,13 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
goto err_undo_flags;
}
if (slave_dev->get_stats == NULL) {
printk(KERN_NOTICE DRV_NAME
": %s: the driver for slave device %s does not provide "
"get_stats function, network statistics will be "
"inaccurate.\n", bond_dev->name, slave_dev->name);
}
new_slave = kmalloc(sizeof(struct slave), GFP_KERNEL);
if (!new_slave) {
res = -ENOMEM;
@ -3605,6 +3612,7 @@ static struct net_device_stats *bond_get_stats(struct net_device *bond_dev)
read_lock_bh(&bond->lock);
bond_for_each_slave(bond, slave, i) {
if (slave->dev->get_stats) {
sstats = slave->dev->get_stats(slave->dev);
stats->rx_packets += sstats->rx_packets;
@ -3633,6 +3641,7 @@ static struct net_device_stats *bond_get_stats(struct net_device *bond_dev)
stats->tx_heartbeat_errors += sstats->tx_heartbeat_errors;
stats->tx_window_errors += sstats->tx_window_errors;
}
}
read_unlock_bh(&bond->lock);