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 9ead30bd00c4..6b92e383c653 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -674,6 +674,7 @@ static void virtnet_set_rx_mode(struct net_device *dev)
674 struct virtio_net_ctrl_mac *mac_data; 674 struct virtio_net_ctrl_mac *mac_data;
675 struct dev_addr_list *addr; 675 struct dev_addr_list *addr;
676 struct netdev_hw_addr *ha; 676 struct netdev_hw_addr *ha;
677 int uc_count;
677 void *buf; 678 void *buf;
678 int i; 679 int i;
679 680
@@ -700,8 +701,9 @@ static void virtnet_set_rx_mode(struct net_device *dev)
700 dev_warn(&dev->dev, "Failed to %sable allmulti mode.\n", 701 dev_warn(&dev->dev, "Failed to %sable allmulti mode.\n",
701 allmulti ? "en" : "dis"); 702 allmulti ? "en" : "dis");
702 703
704 uc_count = netdev_uc_count(dev);
703 /* MAC filter - use one buffer for both lists */ 705 /* MAC filter - use one buffer for both lists */
704 mac_data = buf = kzalloc(((dev->uc.count + dev->mc_count) * ETH_ALEN) + 706 mac_data = buf = kzalloc(((uc_count + dev->mc_count) * ETH_ALEN) +
705 (2 * sizeof(mac_data->entries)), GFP_ATOMIC); 707 (2 * sizeof(mac_data->entries)), GFP_ATOMIC);
706 if (!buf) { 708 if (!buf) {
707 dev_warn(&dev->dev, "No memory for MAC address buffer\n"); 709 dev_warn(&dev->dev, "No memory for MAC address buffer\n");
@@ -711,16 +713,16 @@ static void virtnet_set_rx_mode(struct net_device *dev)
711 sg_init_table(sg, 2); 713 sg_init_table(sg, 2);
712 714
713 /* Store the unicast list and count in the front of the buffer */ 715 /* Store the unicast list and count in the front of the buffer */
714 mac_data->entries = dev->uc.count; 716 mac_data->entries = uc_count;
715 i = 0; 717 i = 0;
716 list_for_each_entry(ha, &dev->uc.list, list) 718 netdev_for_each_uc_addr(ha, dev)
717 memcpy(&mac_data->macs[i++][0], ha->addr, ETH_ALEN); 719 memcpy(&mac_data->macs[i++][0], ha->addr, ETH_ALEN);
718 720
719 sg_set_buf(&sg[0], mac_data, 721 sg_set_buf(&sg[0], mac_data,
720 sizeof(mac_data->entries) + (dev->uc.count * ETH_ALEN)); 722 sizeof(mac_data->entries) + (uc_count * ETH_ALEN));
721 723
722 /* multicast list and count fill the end */ 724 /* multicast list and count fill the end */
723 mac_data = (void *)&mac_data->macs[dev->uc.count][0]; 725 mac_data = (void *)&mac_data->macs[uc_count][0];
724 726
725 mac_data->entries = dev->mc_count; 727 mac_data->entries = dev->mc_count;
726 addr = dev->mc_list; 728 addr = dev->mc_list;