From: Olliver Schinagl Date: Wed, 24 May 2023 10:58:37 +0000 (+0200) Subject: realtek: eth: Do not write directly to dev->addr X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=d881f65da1e6f3bc4237b39cf2373bef51c3828c;p=openwrt%2Fstaging%2Fnbd.git realtek: eth: Do not write directly to dev->addr One is never to write to dev->addr directly. In 6.1 it will be a const and with the newly enabled WERROR, we get a failing grade. Lets fix this ahead of time. Signed-off-by: Olliver Schinagl --- diff --git a/target/linux/realtek/files-5.15/drivers/net/ethernet/rtl838x_eth.c b/target/linux/realtek/files-5.15/drivers/net/ethernet/rtl838x_eth.c index e9ebc7c73c..9dcb7a3b78 100644 --- a/target/linux/realtek/files-5.15/drivers/net/ethernet/rtl838x_eth.c +++ b/target/linux/realtek/files-5.15/drivers/net/ethernet/rtl838x_eth.c @@ -1557,7 +1557,7 @@ static int rtl838x_set_mac_address(struct net_device *dev, void *p) if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL; - memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); + dev_addr_set(dev, addr->sa_data); rtl838x_set_mac_hw(dev, mac); pr_info("Using MAC %08x%08x\n", sw_r32(priv->r->mac), sw_r32(priv->r->mac + 4)); @@ -2352,6 +2352,7 @@ static int __init rtl838x_eth_probe(struct platform_device *pdev) struct resource *res, *mem; phy_interface_t phy_mode; struct phylink *phylink; + u8 mac_addr[ETH_ALEN]; int err = 0, rxrings, rxringlen; struct ring_b *ring; @@ -2478,17 +2479,18 @@ static int __init rtl838x_eth_probe(struct platform_device *pdev) * 1) from device tree data * 2) from internal registers set by bootloader */ - of_get_mac_address(pdev->dev.of_node, dev->dev_addr); - if (is_valid_ether_addr(dev->dev_addr)) { - rtl838x_set_mac_hw(dev, (u8 *)dev->dev_addr); + of_get_mac_address(pdev->dev.of_node, mac_addr); + if (is_valid_ether_addr(mac_addr)) { + rtl838x_set_mac_hw(dev, mac_addr); } else { - dev->dev_addr[0] = (sw_r32(priv->r->mac) >> 8) & 0xff; - dev->dev_addr[1] = sw_r32(priv->r->mac) & 0xff; - dev->dev_addr[2] = (sw_r32(priv->r->mac + 4) >> 24) & 0xff; - dev->dev_addr[3] = (sw_r32(priv->r->mac + 4) >> 16) & 0xff; - dev->dev_addr[4] = (sw_r32(priv->r->mac + 4) >> 8) & 0xff; - dev->dev_addr[5] = sw_r32(priv->r->mac + 4) & 0xff; - } + mac_addr[0] = (sw_r32(priv->r->mac) >> 8) & 0xff; + mac_addr[1] = sw_r32(priv->r->mac) & 0xff; + mac_addr[2] = (sw_r32(priv->r->mac + 4) >> 24) & 0xff; + mac_addr[3] = (sw_r32(priv->r->mac + 4) >> 16) & 0xff; + mac_addr[4] = (sw_r32(priv->r->mac + 4) >> 8) & 0xff; + mac_addr[5] = sw_r32(priv->r->mac + 4) & 0xff; + } + dev_addr_set(dev, mac_addr); /* if the address is invalid, use a random value */ if (!is_valid_ether_addr(dev->dev_addr)) { struct sockaddr sa = { AF_UNSPEC };