diff options
| author | Olliver Schinagl <oliver@schinagl.nl> | 2023-05-24 12:58:37 +0200 |
|---|---|---|
| committer | Christian Lamparter <chunkeey@gmail.com> | 2023-06-03 21:15:11 +0200 |
| commit | d881f65da1e6f3bc4237b39cf2373bef51c3828c (patch) | |
| tree | da509d31ecd48fa17f6bb4b3a8a9bb231cf52e36 /target/linux | |
| parent | 9fb1dbb1df35911b407fa0faaa2443fbc0f0ddde (diff) | |
| download | upstream-d881f65da1e6f3bc4237b39cf2373bef51c3828c.tar.gz upstream-d881f65da1e6f3bc4237b39cf2373bef51c3828c.tar.bz2 upstream-d881f65da1e6f3bc4237b39cf2373bef51c3828c.zip | |
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 <oliver@schinagl.nl>
Diffstat (limited to 'target/linux')
| -rw-r--r-- | target/linux/realtek/files-5.15/drivers/net/ethernet/rtl838x_eth.c | 24 |
1 files changed, 13 insertions, 11 deletions
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 e9ebc7c73c8..9dcb7a3b78e 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 }; |
