Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 40373e2b authored by Jakub Kicinski's avatar Jakub Kicinski Committed by Greg Kroah-Hartman
Browse files

net: usb: don't write directly to netdev->dev_addr



[ Upstream commit 2674e7ea22ba0e22a2d1603bd51e0b8f6442a267 ]

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 got through appropriate helpers.

Manually fix all net/usb drivers without separate maintainers.

v2: catc does DMA to the buffer, leave the conversion to Oliver

Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Stable-dep-of: bab8eb0dd4cb ("usbnet: modern method to get random MAC")
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 3f255eda
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -338,6 +338,7 @@ static int ch9200_bind(struct usbnet *dev, struct usb_interface *intf)
{
	int retval = 0;
	unsigned char data[2];
	u8 addr[ETH_ALEN];

	retval = usbnet_get_endpoints(dev, intf);
	if (retval)
@@ -385,7 +386,8 @@ static int ch9200_bind(struct usbnet *dev, struct usb_interface *intf)
	retval = control_write(dev, REQUEST_WRITE, 0, MAC_REG_CTRL, data, 0x02,
			       CONTROL_TIMEOUT_MS);

	retval = get_mac_address(dev, dev->net->dev_addr);
	retval = get_mac_address(dev, addr);
	eth_hw_addr_set(dev->net, addr);

	return retval;
}
+3 −2
Original line number Diff line number Diff line
@@ -161,6 +161,7 @@ static int cx82310_bind(struct usbnet *dev, struct usb_interface *intf)
	u8 link[3];
	int timeout = 50;
	struct cx82310_priv *priv;
	u8 addr[ETH_ALEN];

	/* avoid ADSL modems - continue only if iProduct is "USB NET CARD" */
	if (usb_string(udev, udev->descriptor.iProduct, buf, sizeof(buf)) > 0
@@ -216,12 +217,12 @@ static int cx82310_bind(struct usbnet *dev, struct usb_interface *intf)
		goto err;

	/* get the MAC address */
	ret = cx82310_cmd(dev, CMD_GET_MAC_ADDR, true, NULL, 0,
			  dev->net->dev_addr, ETH_ALEN);
	ret = cx82310_cmd(dev, CMD_GET_MAC_ADDR, true, NULL, 0, addr, ETH_ALEN);
	if (ret) {
		dev_err(&udev->dev, "unable to read MAC address: %d\n", ret);
		goto err;
	}
	eth_hw_addr_set(dev->net, addr);

	/* start (does not seem to have any effect?) */
	ret = cx82310_cmd(dev, CMD_START, false, NULL, 0, NULL, 0);
+1 −2
Original line number Diff line number Diff line
@@ -1139,8 +1139,7 @@ static int kaweth_probe(
		goto err_all_but_rxbuf;

	memcpy(netdev->broadcast, &bcast_addr, sizeof(bcast_addr));
	memcpy(netdev->dev_addr, &kaweth->configuration.hw_addr,
               sizeof(kaweth->configuration.hw_addr));
	eth_hw_addr_set(netdev, (u8 *)&kaweth->configuration.hw_addr);

	netdev->netdev_ops = &kaweth_netdev_ops;
	netdev->watchdog_timeo = KAWETH_TX_TIMEOUT;
+3 −1
Original line number Diff line number Diff line
@@ -493,17 +493,19 @@ static const struct net_device_ops mcs7830_netdev_ops = {
static int mcs7830_bind(struct usbnet *dev, struct usb_interface *udev)
{
	struct net_device *net = dev->net;
	u8 addr[ETH_ALEN];
	int ret;
	int retry;

	/* Initial startup: Gather MAC address setting from EEPROM */
	ret = -EINVAL;
	for (retry = 0; retry < 5 && ret; retry++)
		ret = mcs7830_hif_get_mac_address(dev, net->dev_addr);
		ret = mcs7830_hif_get_mac_address(dev, addr);
	if (ret) {
		dev_warn(&dev->udev->dev, "Cannot read MAC address\n");
		goto out;
	}
	eth_hw_addr_set(net, addr);

	mcs7830_data_set_multicast(net);

+4 −2
Original line number Diff line number Diff line
@@ -686,6 +686,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
		0x00, 0x00, SIERRA_NET_HIP_MSYNC_ID, 0x00};
	static const u8 shdwn_tmplate[sizeof(priv->shdwn_msg)] = {
		0x00, 0x00, SIERRA_NET_HIP_SHUTD_ID, 0x00};
	u8 mod[2];

	dev_dbg(&dev->udev->dev, "%s", __func__);

@@ -715,8 +716,9 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
	dev->net->netdev_ops = &sierra_net_device_ops;

	/* change MAC addr to include, ifacenum, and to be unique */
	dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
	dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
	mod[0] = atomic_inc_return(&iface_counter);
	mod[1] = ifacenum;
	dev_addr_mod(dev->net, ETH_ALEN - 2, mod, 2);

	/* prepare shutdown message template */
	memcpy(priv->shdwn_msg, shdwn_tmplate, sizeof(priv->shdwn_msg));
Loading