Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

firewire: don't write directly to netdev->dev_addr

Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. To maintain netdev->dev_addr in this tree we need to make all
the writes to it go through appropriate helpers.

Prepare fwnet_hwaddr on the stack and use dev_addr_set() to copy
it to netdev->dev_addr. We no longer need to worry about alignment.
union fwnet_hwaddr does not have any padding and we set all fields
so we don't need to zero it upfront.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jakub Kicinski and committed by
David S. Miller
aaaaa137 707182e4

+7 -7
+7 -7
drivers/firewire/net.c
··· 1443 1443 struct net_device *net; 1444 1444 bool allocated_netdev = false; 1445 1445 struct fwnet_device *dev; 1446 + union fwnet_hwaddr ha; 1446 1447 int ret; 1447 - union fwnet_hwaddr *ha; 1448 1448 1449 1449 mutex_lock(&fwnet_device_mutex); 1450 1450 ··· 1491 1491 net->max_mtu = 4096U; 1492 1492 1493 1493 /* Set our hardware address while we're at it */ 1494 - ha = (union fwnet_hwaddr *)net->dev_addr; 1495 - put_unaligned_be64(card->guid, &ha->uc.uniq_id); 1496 - ha->uc.max_rec = dev->card->max_receive; 1497 - ha->uc.sspd = dev->card->link_speed; 1498 - put_unaligned_be16(dev->local_fifo >> 32, &ha->uc.fifo_hi); 1499 - put_unaligned_be32(dev->local_fifo & 0xffffffff, &ha->uc.fifo_lo); 1494 + ha.uc.uniq_id = cpu_to_be64(card->guid); 1495 + ha.uc.max_rec = dev->card->max_receive; 1496 + ha.uc.sspd = dev->card->link_speed; 1497 + ha.uc.fifo_hi = cpu_to_be16(dev->local_fifo >> 32); 1498 + ha.uc.fifo_lo = cpu_to_be32(dev->local_fifo & 0xffffffff); 1499 + dev_addr_set(net, ha.u); 1500 1500 1501 1501 memset(net->broadcast, -1, net->addr_len); 1502 1502