aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/virtio_net.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/virtio_net.c')
-rw-r--r--drivers/net/virtio_net.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index c708ecc3cb2e..088332a943f7 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -675,6 +675,7 @@ static void virtnet_set_rx_mode(struct net_device *dev)
675 struct virtio_net_ctrl_mac *mac_data; 675 struct virtio_net_ctrl_mac *mac_data;
676 struct dev_addr_list *addr; 676 struct dev_addr_list *addr;
677 struct netdev_hw_addr *ha; 677 struct netdev_hw_addr *ha;
678 int uc_count;
678 void *buf; 679 void *buf;
679 int i; 680 int i;
680 681
@@ -701,8 +702,9 @@ static void virtnet_set_rx_mode(struct net_device *dev)
701 dev_warn(&dev->dev, "Failed to %sable allmulti mode.\n", 702 dev_warn(&dev->dev, "Failed to %sable allmulti mode.\n",
702 allmulti ? "en" : "dis"); 703 allmulti ? "en" : "dis");
703 704
705 uc_count = netdev_uc_count(dev);
704 /* MAC filter - use one buffer for both lists */ 706 /* MAC filter - use one buffer for both lists */
705 mac_data = buf = kzalloc(((dev->uc.count + dev->mc_count) * ETH_ALEN) + 707 mac_data = buf = kzalloc(((uc_count + dev->mc_count) * ETH_ALEN) +
706 (2 * sizeof(mac_data->entries)), GFP_ATOMIC); 708 (2 * sizeof(mac_data->entries)), GFP_ATOMIC);
707 if (!buf) { 709 if (!buf) {
708 dev_warn(&dev->dev, "No memory for MAC address buffer\n"); 710 dev_warn(&dev->dev, "No memory for MAC address buffer\n");
@@ -712,16 +714,16 @@ static void virtnet_set_rx_mode(struct net_device *dev)
712 sg_init_table(sg, 2); 714 sg_init_table(sg, 2);
713 715
714 /* Store the unicast list and count in the front of the buffer */ 716 /* Store the unicast list and count in the front of the buffer */
715 mac_data->entries = dev->uc.count; 717 mac_data->entries = uc_count;
716 i = 0; 718 i = 0;
717 list_for_each_entry(ha, &dev->uc.list, list) 719 netdev_for_each_uc_addr(ha, dev)
718 memcpy(&mac_data->macs[i++][0], ha->addr, ETH_ALEN); 720 memcpy(&mac_data->macs[i++][0], ha->addr, ETH_ALEN);
719 721
720 sg_set_buf(&sg[0], mac_data, 722 sg_set_buf(&sg[0], mac_data,
721 sizeof(mac_data->entries) + (dev->uc.count * ETH_ALEN)); 723 sizeof(mac_data->entries) + (uc_count * ETH_ALEN));
722 724
723 /* multicast list and count fill the end */ 725 /* multicast list and count fill the end */
724 mac_data = (void *)&mac_data->macs[dev->uc.count][0]; 726 mac_data = (void *)&mac_data->macs[uc_count][0];
725 727
726 mac_data->entries = dev->mc_count; 728 mac_data->entries = dev->mc_count;
727 addr = dev->mc_list; 729 addr = dev->mc_list;