linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] staging: prepare for const netdev->dev_addr
@ 2021-10-19 17:12 Jakub Kicinski
  2021-10-19 17:12 ` [PATCH 1/8] staging: use eth_hw_addr_set() Jakub Kicinski
                   ` (8 more replies)
  0 siblings, 9 replies; 16+ messages in thread
From: Jakub Kicinski @ 2021-10-19 17:12 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, Jakub Kicinski

Hi Greg,

This set prepares staging for netdev->dev_addr being const.
We need to sprinkle const around some variables and arguments
and use appropriate helpers to write to netdev->dev_addr.

I'll do another pass over staging before the merge window,
this set is based on what's already there in net-next.

Jakub Kicinski (8):
  staging: use eth_hw_addr_set()
  staging: use eth_hw_addr_set() instead of ether_addr_copy()
  staging: use eth_hw_addr_set() for dev->addr_len cases
  staging: qlge: use eth_hw_addr_set()
  staging: rtl8712: prepare for const netdev->dev_addr
  staging: unisys: use eth_hw_addr_set()
  staging: rtl: use eth_hw_addr_set()
  staging: use eth_hw_addr_set() in orphan drivers

 drivers/staging/gdm724x/gdm_lte.c              |  4 +++-
 drivers/staging/ks7010/ks_hostif.c             |  2 +-
 drivers/staging/ks7010/ks_wlan_net.c           |  4 ++--
 drivers/staging/most/net/net.c                 |  2 +-
 drivers/staging/octeon/ethernet.c              |  2 +-
 drivers/staging/qlge/qlge_main.c               | 18 +++++++-----------
 drivers/staging/qlge/qlge_mpi.c                |  2 +-
 drivers/staging/r8188eu/os_dep/osdep_service.c |  2 +-
 drivers/staging/r8188eu/os_dep/usb_intf.c      |  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c |  7 +++++--
 drivers/staging/rtl8192e/rtl8192e/rtl_cam.c    |  4 ++--
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c   |  2 +-
 drivers/staging/rtl8192u/r8192U.h              |  3 ++-
 drivers/staging/rtl8192u/r8192U_core.c         | 15 +++++++++------
 drivers/staging/rtl8712/os_intfs.c             |  9 +++++----
 drivers/staging/rtl8712/rtl871x_cmd.c          |  2 +-
 drivers/staging/rtl8712/rtl871x_cmd.h          |  2 +-
 drivers/staging/rtl8712/usb_intf.c             |  2 +-
 drivers/staging/rtl8723bs/os_dep/os_intfs.c    |  4 ++--
 .../staging/rtl8723bs/os_dep/osdep_service.c   |  2 +-
 .../staging/unisys/visornic/visornic_main.c    |  5 +++--
 drivers/staging/wlan-ng/p80211netdev.c         |  2 +-
 drivers/staging/wlan-ng/prism2sta.c            |  4 +++-
 23 files changed, 55 insertions(+), 46 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/8] staging: use eth_hw_addr_set()
  2021-10-19 17:12 [PATCH 0/8] staging: prepare for const netdev->dev_addr Jakub Kicinski
@ 2021-10-19 17:12 ` Jakub Kicinski
  2021-10-19 17:12 ` [PATCH 2/8] staging: use eth_hw_addr_set() instead of ether_addr_copy() Jakub Kicinski
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Jakub Kicinski @ 2021-10-19 17:12 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, Jakub Kicinski

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.

Convert staging drivers from memcpy(... ETH_ADDR) to eth_hw_addr_set():

  @@
  expression dev, np;
  @@
  - memcpy(dev->dev_addr, np, ETH_ALEN)
  + eth_hw_addr_set(dev, np)
  @@
  - memcpy(dev->dev_addr, np, 6)
  + eth_hw_addr_set(dev, np)

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/staging/r8188eu/os_dep/osdep_service.c   | 2 +-
 drivers/staging/r8188eu/os_dep/usb_intf.c        | 2 +-
 drivers/staging/rtl8192u/r8192U_core.c           | 2 +-
 drivers/staging/rtl8712/os_intfs.c               | 4 ++--
 drivers/staging/rtl8723bs/os_dep/os_intfs.c      | 2 +-
 drivers/staging/rtl8723bs/os_dep/osdep_service.c | 2 +-
 6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c
index d7d03c1417fd..6bee194fc35d 100644
--- a/drivers/staging/r8188eu/os_dep/osdep_service.c
+++ b/drivers/staging/r8188eu/os_dep/osdep_service.c
@@ -175,7 +175,7 @@ int rtw_change_ifname(struct adapter *padapter, const char *ifname)
 
 	rtw_init_netdev_name(pnetdev, ifname);
 
-	memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN);
+	eth_hw_addr_set(pnetdev, padapter->eeprompriv.mac_addr);
 
 	if (!rtnl_is_locked())
 		ret = register_netdev(pnetdev);
diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c
index 4b8a3e821b74..40f2481afc6f 100644
--- a/drivers/staging/r8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/r8188eu/os_dep/usb_intf.c
@@ -406,7 +406,7 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
 	rtw_macaddr_cfg(padapter->eeprompriv.mac_addr);
 	rtw_init_wifidirect_addrs(padapter, padapter->eeprompriv.mac_addr,
 				  padapter->eeprompriv.mac_addr);
-	memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN);
+	eth_hw_addr_set(pnetdev, padapter->eeprompriv.mac_addr);
 	DBG_88E("MAC Address from pnetdev->dev_addr =  %pM\n",
 		pnetdev->dev_addr);
 
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 594239990455..2aaba44d84e2 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -2307,7 +2307,7 @@ static int rtl8192_read_eeprom_info(struct net_device *dev)
 			*(u16 *)(&dev->dev_addr[i]) = (u16)ret;
 		}
 	} else {
-		memcpy(dev->dev_addr, bMac_Tmp_Addr, 6);
+		eth_hw_addr_set(dev, bMac_Tmp_Addr);
 		/* should I set IDR0 here? */
 	}
 	RT_TRACE(COMP_EPROM, "MAC addr:%pM\n", dev->dev_addr);
diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c
index 9502f6aa5306..2d3233a650fc 100644
--- a/drivers/staging/rtl8712/os_intfs.c
+++ b/drivers/staging/rtl8712/os_intfs.c
@@ -381,8 +381,8 @@ static int netdev_open(struct net_device *pnetdev)
 			goto netdev_open_error;
 		if (!r8712_initmac) {
 			/* Use the mac address stored in the Efuse */
-			memcpy(pnetdev->dev_addr,
-			       padapter->eeprompriv.mac_addr, ETH_ALEN);
+			eth_hw_addr_set(pnetdev,
+					padapter->eeprompriv.mac_addr);
 		} else {
 			/* We have to inform f/w to use user-supplied MAC
 			 * address.
diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
index 1b8b76f14740..719e75ee3fb2 100644
--- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
@@ -789,7 +789,7 @@ static int _rtw_drv_register_netdev(struct adapter *padapter, char *name)
 	if (rtw_init_netdev_name(pnetdev, name))
 		return _FAIL;
 
-	memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN);
+	eth_hw_addr_set(pnetdev, padapter->eeprompriv.mac_addr);
 
 	/* Tell the network stack we exist */
 	if (register_netdev(pnetdev) != 0) {
diff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
index d6bddf7b08e8..4fbfa75c05d7 100644
--- a/drivers/staging/rtl8723bs/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
@@ -142,7 +142,7 @@ int rtw_change_ifname(struct adapter *padapter, const char *ifname)
 
 	rtw_init_netdev_name(pnetdev, ifname);
 
-	memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN);
+	eth_hw_addr_set(pnetdev, padapter->eeprompriv.mac_addr);
 
 	if (!rtnl_is_locked())
 		ret = register_netdev(pnetdev);
-- 
2.31.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 2/8] staging: use eth_hw_addr_set() instead of ether_addr_copy()
  2021-10-19 17:12 [PATCH 0/8] staging: prepare for const netdev->dev_addr Jakub Kicinski
  2021-10-19 17:12 ` [PATCH 1/8] staging: use eth_hw_addr_set() Jakub Kicinski
@ 2021-10-19 17:12 ` Jakub Kicinski
  2021-10-19 17:12 ` [PATCH 3/8] staging: use eth_hw_addr_set() for dev->addr_len cases Jakub Kicinski
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Jakub Kicinski @ 2021-10-19 17:12 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, Jakub Kicinski

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.

Convert staging from ether_addr_copy() to eth_hw_addr_set():

  @@
  expression dev, np;
  @@
  - ether_addr_copy(dev->dev_addr, np)
  + eth_hw_addr_set(dev, np)

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/staging/ks7010/ks_hostif.c             | 2 +-
 drivers/staging/ks7010/ks_wlan_net.c           | 2 +-
 drivers/staging/most/net/net.c                 | 2 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c   | 2 +-
 drivers/staging/rtl8192u/r8192U_core.c         | 2 +-
 drivers/staging/rtl8712/os_intfs.c             | 2 +-
 drivers/staging/rtl8712/usb_intf.c             | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index eaa70893224a..1c63d595313d 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -541,7 +541,7 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
 		hostif_sme_enqueue(priv, SME_GET_MAC_ADDRESS);
 		ether_addr_copy(priv->eth_addr, priv->rxp);
 		priv->mac_address_valid = true;
-		ether_addr_copy(dev->dev_addr, priv->eth_addr);
+		eth_hw_addr_set(dev, priv->eth_addr);
 		netdev_info(dev, "MAC ADDRESS = %pM\n", priv->eth_addr);
 		break;
 	case DOT11_PRODUCT_VERSION:
diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
index 631ad769c3d5..61d8f40e2739 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -2625,7 +2625,7 @@ int ks_wlan_net_start(struct net_device *dev)
 
 	/* dummy address set */
 	ether_addr_copy(priv->eth_addr, dummy_addr);
-	ether_addr_copy(dev->dev_addr, priv->eth_addr);
+	eth_hw_addr_set(dev, priv->eth_addr);
 
 	/* The ks_wlan-specific entries in the device structure. */
 	dev->netdev_ops = &ks_wlan_netdev_ops;
diff --git a/drivers/staging/most/net/net.c b/drivers/staging/most/net/net.c
index a5fd14246046..47039f0d262f 100644
--- a/drivers/staging/most/net/net.c
+++ b/drivers/staging/most/net/net.c
@@ -564,7 +564,7 @@ static void on_netinfo(struct most_interface *iface,
 	if (m && is_valid_ether_addr(m)) {
 		if (!is_valid_ether_addr(dev->dev_addr)) {
 			netdev_info(dev, "set mac %pM\n", m);
-			ether_addr_copy(dev->dev_addr, m);
+			eth_hw_addr_set(dev, m);
 			netif_dormant_off(dev);
 		} else if (!ether_addr_equal(dev->dev_addr, m)) {
 			netdev_warn(dev, "reject mac %pM\n", m);
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
index 358b629d2cc6..cfeaa9c1542f 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
@@ -366,7 +366,7 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev)
 			*(u16 *)(&dev->dev_addr[i]) = usValue;
 		}
 	} else {
-		ether_addr_copy(dev->dev_addr, bMac_Tmp_Addr);
+		eth_hw_addr_set(dev, bMac_Tmp_Addr);
 	}
 
 	RT_TRACE(COMP_INIT, "Permanent Address = %pM\n",
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index a7dd1578b2c6..d2e9df60e9ba 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -2235,7 +2235,7 @@ static int _rtl92e_set_mac_adr(struct net_device *dev, void *mac)
 
 	mutex_lock(&priv->wx_mutex);
 
-	ether_addr_copy(dev->dev_addr, addr->sa_data);
+	eth_hw_addr_set(dev, addr->sa_data);
 
 	schedule_work(&priv->reset_wq);
 	mutex_unlock(&priv->wx_mutex);
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 2aaba44d84e2..3718d72e217e 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -3454,7 +3454,7 @@ static int r8192_set_mac_adr(struct net_device *dev, void *mac)
 
 	mutex_lock(&priv->wx_mutex);
 
-	ether_addr_copy(dev->dev_addr, addr->sa_data);
+	eth_hw_addr_set(dev, addr->sa_data);
 
 	schedule_work(&priv->reset_wq);
 	mutex_unlock(&priv->wx_mutex);
diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c
index 2d3233a650fc..beb9137c198c 100644
--- a/drivers/staging/rtl8712/os_intfs.c
+++ b/drivers/staging/rtl8712/os_intfs.c
@@ -166,7 +166,7 @@ static int r871x_net_set_mac_address(struct net_device *pnetdev, void *p)
 	struct sockaddr *addr = p;
 
 	if (!padapter->bup)
-		ether_addr_copy(pnetdev->dev_addr, addr->sa_data);
+		eth_hw_addr_set(pnetdev, addr->sa_data);
 	return 0;
 }
 
diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c
index 505ebeb643dc..17e705411e64 100644
--- a/drivers/staging/rtl8712/usb_intf.c
+++ b/drivers/staging/rtl8712/usb_intf.c
@@ -563,7 +563,7 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf,
 			dev_info(&udev->dev,
 				"r8712u: MAC Address from efuse = %pM\n", mac);
 		}
-		ether_addr_copy(pnetdev->dev_addr, mac);
+		eth_hw_addr_set(pnetdev, mac);
 	}
 	/* step 6. Load the firmware asynchronously */
 	if (rtl871x_load_fw(padapter))
-- 
2.31.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 3/8] staging: use eth_hw_addr_set() for dev->addr_len cases
  2021-10-19 17:12 [PATCH 0/8] staging: prepare for const netdev->dev_addr Jakub Kicinski
  2021-10-19 17:12 ` [PATCH 1/8] staging: use eth_hw_addr_set() Jakub Kicinski
  2021-10-19 17:12 ` [PATCH 2/8] staging: use eth_hw_addr_set() instead of ether_addr_copy() Jakub Kicinski
@ 2021-10-19 17:12 ` Jakub Kicinski
  2021-10-19 17:12 ` [PATCH 4/8] staging: qlge: use eth_hw_addr_set() Jakub Kicinski
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Jakub Kicinski @ 2021-10-19 17:12 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, Jakub Kicinski

Convert all staging drivers from memcpy(... dev->addr_len)
to eth_hw_addr_set():

  @@
  expression dev, np;
  @@
  - memcpy(dev->dev_addr, np, dev->addr_len)
  + eth_hw_addr_set(dev, np)

Manually confirmed these are all etherdevices.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/staging/ks7010/ks_wlan_net.c   |  2 +-
 drivers/staging/qlge/qlge_main.c       | 10 +++-------
 drivers/staging/wlan-ng/p80211netdev.c |  2 +-
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
index 61d8f40e2739..7e8d37c169f0 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -2490,7 +2490,7 @@ int ks_wlan_set_mac_address(struct net_device *dev, void *addr)
 
 	if (netif_running(dev))
 		return -EBUSY;
-	memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len);
+	eth_hw_addr_set(dev, mac_addr->sa_data);
 	ether_addr_copy(priv->eth_addr, mac_addr->sa_data);
 
 	priv->mac_address_valid = false;
diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c
index 8fcdf89da8aa..abb7844f92fb 100644
--- a/drivers/staging/qlge/qlge_main.c
+++ b/drivers/staging/qlge/qlge_main.c
@@ -724,9 +724,7 @@ static int qlge_get_8000_flash_params(struct qlge_adapter *qdev)
 		goto exit;
 	}
 
-	memcpy(qdev->ndev->dev_addr,
-	       mac_addr,
-	       qdev->ndev->addr_len);
+	eth_hw_addr_set(qdev->ndev, mac_addr);
 
 exit:
 	qlge_sem_unlock(qdev, SEM_FLASH_MASK);
@@ -774,9 +772,7 @@ static int qlge_get_8012_flash_params(struct qlge_adapter *qdev)
 		goto exit;
 	}
 
-	memcpy(qdev->ndev->dev_addr,
-	       qdev->flash.flash_params_8012.mac_addr,
-	       qdev->ndev->addr_len);
+	eth_hw_addr_set(qdev->ndev, qdev->flash.flash_params_8012.mac_addr);
 
 exit:
 	qlge_sem_unlock(qdev, SEM_FLASH_MASK);
@@ -4214,7 +4210,7 @@ static int qlge_set_mac_address(struct net_device *ndev, void *p)
 
 	if (!is_valid_ether_addr(addr->sa_data))
 		return -EADDRNOTAVAIL;
-	memcpy(ndev->dev_addr, addr->sa_data, ndev->addr_len);
+	eth_hw_addr_set(ndev, addr->sa_data);
 	/* Update local copy of current mac address. */
 	memcpy(qdev->current_mac_addr, ndev->dev_addr, ndev->addr_len);
 
diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c
index 07ed6c4cfdcc..255500448ad3 100644
--- a/drivers/staging/wlan-ng/p80211netdev.c
+++ b/drivers/staging/wlan-ng/p80211netdev.c
@@ -616,7 +616,7 @@ static int p80211knetdev_set_mac_address(struct net_device *dev, void *addr)
 		result = -EADDRNOTAVAIL;
 	} else {
 		/* everything's ok, change the addr in netdev */
-		memcpy(dev->dev_addr, new_addr->sa_data, dev->addr_len);
+		eth_hw_addr_set(dev, new_addr->sa_data);
 	}
 
 	return result;
-- 
2.31.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 4/8] staging: qlge: use eth_hw_addr_set()
  2021-10-19 17:12 [PATCH 0/8] staging: prepare for const netdev->dev_addr Jakub Kicinski
                   ` (2 preceding siblings ...)
  2021-10-19 17:12 ` [PATCH 3/8] staging: use eth_hw_addr_set() for dev->addr_len cases Jakub Kicinski
@ 2021-10-19 17:12 ` Jakub Kicinski
  2021-10-19 17:12 ` [PATCH 5/8] staging: rtl8712: prepare for const netdev->dev_addr Jakub Kicinski
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Jakub Kicinski @ 2021-10-19 17:12 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, Jakub Kicinski, manishc, GR-Linux-NIC-Dev, coiby.xu

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.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: manishc@marvell.com
CC: GR-Linux-NIC-Dev@marvell.com
CC: coiby.xu@gmail.com
CC: gregkh@linuxfoundation.org
CC: linux-staging@lists.linux.dev
---
 drivers/staging/qlge/qlge_main.c | 8 ++++----
 drivers/staging/qlge/qlge_mpi.c  | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c
index abb7844f92fb..ee6b49ca2ddf 100644
--- a/drivers/staging/qlge/qlge_main.c
+++ b/drivers/staging/qlge/qlge_main.c
@@ -321,8 +321,8 @@ int qlge_get_mac_addr_reg(struct qlge_adapter *qdev, u32 type, u16 index,
 /* Set up a MAC, multicast or VLAN address for the
  * inbound frame matching.
  */
-static int qlge_set_mac_addr_reg(struct qlge_adapter *qdev, u8 *addr, u32 type,
-				 u16 index)
+static int qlge_set_mac_addr_reg(struct qlge_adapter *qdev, const u8 *addr,
+				 u32 type, u16 index)
 {
 	u32 offset = 0;
 	int status = 0;
@@ -441,7 +441,7 @@ static int qlge_set_mac_addr(struct qlge_adapter *qdev, int set)
 	status = qlge_sem_spinlock(qdev, SEM_MAC_ADDR_MASK);
 	if (status)
 		return status;
-	status = qlge_set_mac_addr_reg(qdev, (u8 *)addr,
+	status = qlge_set_mac_addr_reg(qdev, (const u8 *)addr,
 				       MAC_ADDR_TYPE_CAM_MAC,
 				       qdev->func * MAX_CQ);
 	qlge_sem_unlock(qdev, SEM_MAC_ADDR_MASK);
@@ -4217,7 +4217,7 @@ static int qlge_set_mac_address(struct net_device *ndev, void *p)
 	status = qlge_sem_spinlock(qdev, SEM_MAC_ADDR_MASK);
 	if (status)
 		return status;
-	status = qlge_set_mac_addr_reg(qdev, (u8 *)ndev->dev_addr,
+	status = qlge_set_mac_addr_reg(qdev, (const u8 *)ndev->dev_addr,
 				       MAC_ADDR_TYPE_CAM_MAC,
 				       qdev->func * MAX_CQ);
 	if (status)
diff --git a/drivers/staging/qlge/qlge_mpi.c b/drivers/staging/qlge/qlge_mpi.c
index 2630ebf50341..96a4de6d2b34 100644
--- a/drivers/staging/qlge/qlge_mpi.c
+++ b/drivers/staging/qlge/qlge_mpi.c
@@ -862,7 +862,7 @@ int qlge_mb_wol_set_magic(struct qlge_adapter *qdev, u32 enable_wol)
 	struct mbox_params mbc;
 	struct mbox_params *mbcp = &mbc;
 	int status;
-	u8 *addr = qdev->ndev->dev_addr;
+	const u8 *addr = qdev->ndev->dev_addr;
 
 	memset(mbcp, 0, sizeof(struct mbox_params));
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 5/8] staging: rtl8712: prepare for const netdev->dev_addr
  2021-10-19 17:12 [PATCH 0/8] staging: prepare for const netdev->dev_addr Jakub Kicinski
                   ` (3 preceding siblings ...)
  2021-10-19 17:12 ` [PATCH 4/8] staging: qlge: use eth_hw_addr_set() Jakub Kicinski
@ 2021-10-19 17:12 ` Jakub Kicinski
  2021-10-19 17:12 ` [PATCH 6/8] staging: unisys: use eth_hw_addr_set() Jakub Kicinski
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Jakub Kicinski @ 2021-10-19 17:12 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, Jakub Kicinski

netdev->dev_addr will be const soon, make sure the qualifier
is respected by drivers.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/staging/rtl8712/os_intfs.c    | 3 ++-
 drivers/staging/rtl8712/rtl871x_cmd.c | 2 +-
 drivers/staging/rtl8712/rtl871x_cmd.h | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c
index beb9137c198c..d15d52c0d1a7 100644
--- a/drivers/staging/rtl8712/os_intfs.c
+++ b/drivers/staging/rtl8712/os_intfs.c
@@ -388,7 +388,8 @@ static int netdev_open(struct net_device *pnetdev)
 			 * address.
 			 */
 			msleep(200);
-			r8712_setMacAddr_cmd(padapter, (u8 *)pnetdev->dev_addr);
+			r8712_setMacAddr_cmd(padapter,
+					     (const u8 *)pnetdev->dev_addr);
 			/*
 			 * The "myid" function will get the wifi mac address
 			 * from eeprompriv structure instead of netdev
diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c
index 75716f59044d..acda930722b2 100644
--- a/drivers/staging/rtl8712/rtl871x_cmd.c
+++ b/drivers/staging/rtl8712/rtl871x_cmd.c
@@ -554,7 +554,7 @@ void r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key)
 	r8712_enqueue_cmd(pcmdpriv, ph2c);
 }
 
-void r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr)
+void r8712_setMacAddr_cmd(struct _adapter *padapter, const u8 *mac_addr)
 {
 	struct cmd_priv	*pcmdpriv = &padapter->cmdpriv;
 	struct cmd_obj *ph2c;
diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h
index bf6f0c6a86e5..ddd69c4ae208 100644
--- a/drivers/staging/rtl8712/rtl871x_cmd.h
+++ b/drivers/staging/rtl8712/rtl871x_cmd.h
@@ -718,7 +718,7 @@ struct DisconnectCtrlEx_param {
 #define H2C_CMD_OVERFLOW		0x06
 #define H2C_RESERVED			0x07
 
-void r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr);
+void r8712_setMacAddr_cmd(struct _adapter *padapter, const u8 *mac_addr);
 u8 r8712_sitesurvey_cmd(struct _adapter *padapter,
 			struct ndis_802_11_ssid *pssid);
 int r8712_createbss_cmd(struct _adapter *padapter);
-- 
2.31.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 6/8] staging: unisys: use eth_hw_addr_set()
  2021-10-19 17:12 [PATCH 0/8] staging: prepare for const netdev->dev_addr Jakub Kicinski
                   ` (4 preceding siblings ...)
  2021-10-19 17:12 ` [PATCH 5/8] staging: rtl8712: prepare for const netdev->dev_addr Jakub Kicinski
@ 2021-10-19 17:12 ` Jakub Kicinski
  2021-10-19 17:12 ` [PATCH 7/8] staging: rtl: " Jakub Kicinski
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Jakub Kicinski @ 2021-10-19 17:12 UTC (permalink / raw)
  To: gregkh
  Cc: linux-staging, Jakub Kicinski, david.kershner, chensong_2000,
	sparmaintainer

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.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: david.kershner@unisys.com
CC: gregkh@linuxfoundation.org
CC: chensong_2000@189.cn
CC: sparmaintainer@unisys.com
CC: linux-staging@lists.linux.dev
---
 drivers/staging/unisys/visornic/visornic_main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/visornic/visornic_main.c b/drivers/staging/unisys/visornic/visornic_main.c
index a3bc568c660d..62cd9b783732 100644
--- a/drivers/staging/unisys/visornic/visornic_main.c
+++ b/drivers/staging/unisys/visornic/visornic_main.c
@@ -1782,6 +1782,7 @@ static int visornic_probe(struct visor_device *dev)
 	struct net_device *netdev = NULL;
 	int err;
 	int channel_offset = 0;
+	u8 addr[ETH_ALEN];
 	u64 features;
 
 	netdev = alloc_etherdev(sizeof(struct visornic_devdata));
@@ -1798,14 +1799,14 @@ static int visornic_probe(struct visor_device *dev)
 	/* Get MAC address from channel and read it into the device. */
 	netdev->addr_len = ETH_ALEN;
 	channel_offset = offsetof(struct visor_io_channel, vnic.macaddr);
-	err = visorbus_read_channel(dev, channel_offset, netdev->dev_addr,
-				    ETH_ALEN);
+	err = visorbus_read_channel(dev, channel_offset, addr, ETH_ALEN);
 	if (err < 0) {
 		dev_err(&dev->device,
 			"%s failed to get mac addr from chan (%d)\n",
 			__func__, err);
 		goto cleanup_netdev;
 	}
+	eth_hw_addr_set(netdev, addr);
 
 	devdata = devdata_initialize(netdev_priv(netdev), dev);
 	if (!devdata) {
-- 
2.31.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 7/8] staging: rtl: use eth_hw_addr_set()
  2021-10-19 17:12 [PATCH 0/8] staging: prepare for const netdev->dev_addr Jakub Kicinski
                   ` (5 preceding siblings ...)
  2021-10-19 17:12 ` [PATCH 6/8] staging: unisys: use eth_hw_addr_set() Jakub Kicinski
@ 2021-10-19 17:12 ` Jakub Kicinski
  2021-11-03 11:29   ` Dan Carpenter
  2021-10-19 17:12 ` [PATCH 8/8] staging: use eth_hw_addr_set() in orphan drivers Jakub Kicinski
  2021-10-19 17:34 ` [PATCH 0/8] staging: prepare for const netdev->dev_addr Greg KH
  8 siblings, 1 reply; 16+ messages in thread
From: Jakub Kicinski @ 2021-10-19 17:12 UTC (permalink / raw)
  To: gregkh
  Cc: linux-staging, Jakub Kicinski, knv418, jiapeng.chong, ojaswin98,
	arnd, lee.jones, clrrm, fabioaiuto83, hdegoede, ross.schm.dev,
	insafonov

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.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: gregkh@linuxfoundation.org
CC: knv418@gmail.com
CC: jiapeng.chong@linux.alibaba.com
CC: ojaswin98@gmail.com
CC: arnd@arndb.de
CC: lee.jones@linaro.org
CC: clrrm@isep.ipp.pt
CC: fabioaiuto83@gmail.com
CC: hdegoede@redhat.com
CC: ross.schm.dev@gmail.com
CC: insafonov@gmail.com
CC: linux-staging@lists.linux.dev
---
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c |  5 ++++-
 drivers/staging/rtl8192e/rtl8192e/rtl_cam.c    |  4 ++--
 drivers/staging/rtl8192u/r8192U.h              |  3 ++-
 drivers/staging/rtl8192u/r8192U_core.c         | 11 +++++++----
 drivers/staging/rtl8723bs/os_dep/os_intfs.c    |  2 +-
 5 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
index cfeaa9c1542f..7f9dee42a04d 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
@@ -360,11 +360,14 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev)
 		 priv->eeprom_CustomerID);
 
 	if (!priv->AutoloadFailFlag) {
+		u8 addr[ETH_ALEN];
+
 		for (i = 0; i < 6; i += 2) {
 			usValue = rtl92e_eeprom_read(dev,
 				 (EEPROM_NODE_ADDRESS_BYTE_0 + i) >> 1);
-			*(u16 *)(&dev->dev_addr[i]) = usValue;
+			*(u16 *)(&addr[i]) = usValue;
 		}
+		eth_hw_addr_set(dev, addr);
 	} else {
 		eth_hw_addr_set(dev, bMac_Tmp_Addr);
 	}
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c
index f75a12543781..d7630f02a910 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c
@@ -184,7 +184,7 @@ void rtl92e_cam_restore(struct net_device *dev)
 		if (priv->rtllib->iw_mode == IW_MODE_ADHOC) {
 			rtl92e_set_key(dev, 4, 0,
 				       priv->rtllib->pairwise_key_type,
-				       (u8 *)dev->dev_addr, 0,
+				       (const u8 *)dev->dev_addr, 0,
 				       (u32 *)(&priv->rtllib->swcamtable[4].key_buf[0]));
 		} else {
 			rtl92e_set_key(dev, 4, 0,
@@ -197,7 +197,7 @@ void rtl92e_cam_restore(struct net_device *dev)
 		if (priv->rtllib->iw_mode == IW_MODE_ADHOC) {
 			rtl92e_set_key(dev, 4, 0,
 				       priv->rtllib->pairwise_key_type,
-				       (u8 *)dev->dev_addr, 0,
+				       (const u8 *)dev->dev_addr, 0,
 				       (u32 *)(&priv->rtllib->swcamtable[4].key_buf[0]));
 		} else {
 			rtl92e_set_key(dev, 4, 0,
diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h
index 4013107cd93a..14ca00a2789b 100644
--- a/drivers/staging/rtl8192u/r8192U.h
+++ b/drivers/staging/rtl8192u/r8192U.h
@@ -1114,6 +1114,7 @@ void rtl8192_set_rxconf(struct net_device *dev);
 void rtl819xusb_beacon_tx(struct net_device *dev, u16 tx_rate);
 
 void EnableHWSecurityConfig8192(struct net_device *dev);
-void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, u8 *MacAddr, u8 DefaultKey, u32 *KeyContent);
+void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType,
+	    const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent);
 
 #endif
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 3718d72e217e..cfbd9d79baa7 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -2300,12 +2300,15 @@ static int rtl8192_read_eeprom_info(struct net_device *dev)
 	/* set channelplan from eeprom */
 	priv->ChannelPlan = priv->eeprom_ChannelPlan;
 	if (bLoad_From_EEPOM) {
+		u8 addr[ETH_ALEN];
+
 		for (i = 0; i < 6; i += 2) {
 			ret = eprom_read(dev, (u16)((EEPROM_NODE_ADDRESS_BYTE_0 + i) >> 1));
 			if (ret < 0)
 				return ret;
-			*(u16 *)(&dev->dev_addr[i]) = (u16)ret;
+			*(u16 *)(&addr[i]) = (u16)ret;
 		}
+		eth_hw_addr_set(dev, addr);
 	} else {
 		eth_hw_addr_set(dev, bMac_Tmp_Addr);
 		/* should I set IDR0 here? */
@@ -3045,14 +3048,14 @@ static void CamRestoreAllEntry(struct net_device *dev)
 	} else if (priv->ieee80211->pairwise_key_type == KEY_TYPE_TKIP) {
 		if (priv->ieee80211->iw_mode == IW_MODE_ADHOC)
 			setKey(dev, 4, 0, priv->ieee80211->pairwise_key_type,
-			       (u8 *)dev->dev_addr, 0, NULL);
+			       (const u8 *)dev->dev_addr, 0, NULL);
 		else
 			setKey(dev, 4, 0, priv->ieee80211->pairwise_key_type,
 			       MacAddr, 0, NULL);
 	} else if (priv->ieee80211->pairwise_key_type == KEY_TYPE_CCMP) {
 		if (priv->ieee80211->iw_mode == IW_MODE_ADHOC)
 			setKey(dev, 4, 0, priv->ieee80211->pairwise_key_type,
-			       (u8 *)dev->dev_addr, 0, NULL);
+			       (const u8 *)dev->dev_addr, 0, NULL);
 		else
 			setKey(dev, 4, 0, priv->ieee80211->pairwise_key_type,
 			       MacAddr, 0, NULL);
@@ -4868,7 +4871,7 @@ void EnableHWSecurityConfig8192(struct net_device *dev)
 }
 
 void setKey(struct net_device *dev, u8 entryno, u8 keyindex, u16 keytype,
-	    u8 *macaddr, u8 defaultkey, u32 *keycontent)
+	    const u8 *macaddr, u8 defaultkey, u32 *keycontent)
 {
 	u32 target_command = 0;
 	u32 target_content = 0;
diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
index 719e75ee3fb2..05482341eefe 100644
--- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
@@ -283,7 +283,7 @@ static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p)
 	if (!padapter->bup) {
 		/* addr->sa_data[4], addr->sa_data[5]); */
 		memcpy(padapter->eeprompriv.mac_addr, addr->sa_data, ETH_ALEN);
-		/* memcpy(pnetdev->dev_addr, addr->sa_data, ETH_ALEN); */
+		/* eth_hw_addr_set(pnetdev, addr->sa_data); */
 		/* padapter->bset_hwaddr = true; */
 	}
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 8/8] staging: use eth_hw_addr_set() in orphan drivers
  2021-10-19 17:12 [PATCH 0/8] staging: prepare for const netdev->dev_addr Jakub Kicinski
                   ` (6 preceding siblings ...)
  2021-10-19 17:12 ` [PATCH 7/8] staging: rtl: " Jakub Kicinski
@ 2021-10-19 17:12 ` Jakub Kicinski
  2021-10-20 16:53   ` Kees Cook
  2021-10-19 17:34 ` [PATCH 0/8] staging: prepare for const netdev->dev_addr Greg KH
  8 siblings, 1 reply; 16+ messages in thread
From: Jakub Kicinski @ 2021-10-19 17:12 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, Jakub Kicinski, keescook

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.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: gregkh@linuxfoundation.org
CC: keescook@chromium.org
CC: linux-staging@lists.linux.dev
---
 drivers/staging/gdm724x/gdm_lte.c   | 4 +++-
 drivers/staging/octeon/ethernet.c   | 2 +-
 drivers/staging/wlan-ng/prism2sta.c | 4 +++-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c
index e390c924ec1c..493ed4821515 100644
--- a/drivers/staging/gdm724x/gdm_lte.c
+++ b/drivers/staging/gdm724x/gdm_lte.c
@@ -867,6 +867,7 @@ int register_lte_device(struct phy_dev *phy_dev,
 	struct nic *nic;
 	struct net_device *net;
 	char pdn_dev_name[16];
+	u8 addr[ETH_ALEN];
 	int ret = 0;
 	u8 index;
 
@@ -893,11 +894,12 @@ int register_lte_device(struct phy_dev *phy_dev,
 		nic->phy_dev = phy_dev;
 		nic->nic_id = index;
 
-		form_mac_address(net->dev_addr,
+		form_mac_address(addr,
 				 nic->src_mac_addr,
 				 nic->dest_mac_addr,
 				 mac_address,
 				 index);
+		eth_hw_addr_set(net, addr);
 
 		SET_NETDEV_DEV(net, dev);
 		SET_NETDEV_DEVTYPE(net, &wwan_type);
diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
index 5d24c1b6663b..bf8c5443a218 100644
--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -350,7 +350,7 @@ static int cvm_oct_set_mac_filter(struct net_device *dev)
 	    (cvmx_helper_interface_get_mode(interface) !=
 		CVMX_HELPER_INTERFACE_MODE_SPI)) {
 		int i;
-		u8 *ptr = dev->dev_addr;
+		const u8 *ptr = dev->dev_addr;
 		u64 mac = 0;
 		int index = INDEX(priv->port);
 
diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c
index 1be43300052f..daa7cc4e897c 100644
--- a/drivers/staging/wlan-ng/prism2sta.c
+++ b/drivers/staging/wlan-ng/prism2sta.c
@@ -585,6 +585,7 @@ static int prism2sta_getcardinfo(struct wlandevice *wlandev)
 	struct hfa384x *hw = wlandev->priv;
 	u16 temp;
 	u8 snum[HFA384x_RID_NICSERIALNUMBER_LEN];
+	u8 addr[ETH_ALEN];
 
 	/* Collect version and compatibility info */
 	/*  Some are critical, some are not */
@@ -855,11 +856,12 @@ static int prism2sta_getcardinfo(struct wlandevice *wlandev)
 
 	/* Collect the MAC address */
 	result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CNFOWNMACADDR,
-					wlandev->netdev->dev_addr, ETH_ALEN);
+					addr, ETH_ALEN);
 	if (result != 0) {
 		netdev_err(wlandev->netdev, "Failed to retrieve mac address\n");
 		goto failed;
 	}
+	eth_hw_addr_set(wlandev->netdev, addr);
 
 	/* short preamble is always implemented */
 	wlandev->nsdcaps |= P80211_NSDCAP_SHORT_PREAMBLE;
-- 
2.31.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/8] staging: prepare for const netdev->dev_addr
  2021-10-19 17:12 [PATCH 0/8] staging: prepare for const netdev->dev_addr Jakub Kicinski
                   ` (7 preceding siblings ...)
  2021-10-19 17:12 ` [PATCH 8/8] staging: use eth_hw_addr_set() in orphan drivers Jakub Kicinski
@ 2021-10-19 17:34 ` Greg KH
  2021-10-19 18:01   ` Jakub Kicinski
  8 siblings, 1 reply; 16+ messages in thread
From: Greg KH @ 2021-10-19 17:34 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: linux-staging

On Tue, Oct 19, 2021 at 10:12:35AM -0700, Jakub Kicinski wrote:
> Hi Greg,
> 
> This set prepares staging for netdev->dev_addr being const.
> We need to sprinkle const around some variables and arguments
> and use appropriate helpers to write to netdev->dev_addr.
> 
> I'll do another pass over staging before the merge window,
> this set is based on what's already there in net-next.

Are these ok to take through my tree now?  Or are you wanting to take
them all through netdev?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/8] staging: prepare for const netdev->dev_addr
  2021-10-19 17:34 ` [PATCH 0/8] staging: prepare for const netdev->dev_addr Greg KH
@ 2021-10-19 18:01   ` Jakub Kicinski
  2021-10-19 18:15     ` Greg KH
  0 siblings, 1 reply; 16+ messages in thread
From: Jakub Kicinski @ 2021-10-19 18:01 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-staging

On Tue, 19 Oct 2021 19:34:18 +0200 Greg KH wrote:
> On Tue, Oct 19, 2021 at 10:12:35AM -0700, Jakub Kicinski wrote:
> > Hi Greg,
> > 
> > This set prepares staging for netdev->dev_addr being const.
> > We need to sprinkle const around some variables and arguments
> > and use appropriate helpers to write to netdev->dev_addr.
> > 
> > I'll do another pass over staging before the merge window,
> > this set is based on what's already there in net-next.  
> 
> Are these ok to take through my tree now?  Or are you wanting to take
> them all through netdev?

I was expecting you to take them, I'll only mark netdev->dev_addr const
after the next merge window so no rush until then. 

And there's already a small conflict between this set if generated on
top of net-next and changes you have in your tree.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/8] staging: prepare for const netdev->dev_addr
  2021-10-19 18:01   ` Jakub Kicinski
@ 2021-10-19 18:15     ` Greg KH
  0 siblings, 0 replies; 16+ messages in thread
From: Greg KH @ 2021-10-19 18:15 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: linux-staging

On Tue, Oct 19, 2021 at 11:01:59AM -0700, Jakub Kicinski wrote:
> On Tue, 19 Oct 2021 19:34:18 +0200 Greg KH wrote:
> > On Tue, Oct 19, 2021 at 10:12:35AM -0700, Jakub Kicinski wrote:
> > > Hi Greg,
> > > 
> > > This set prepares staging for netdev->dev_addr being const.
> > > We need to sprinkle const around some variables and arguments
> > > and use appropriate helpers to write to netdev->dev_addr.
> > > 
> > > I'll do another pass over staging before the merge window,
> > > this set is based on what's already there in net-next.  
> > 
> > Are these ok to take through my tree now?  Or are you wanting to take
> > them all through netdev?
> 
> I was expecting you to take them, I'll only mark netdev->dev_addr const
> after the next merge window so no rush until then. 

Ok, I'll apply them to my tree tomorrow, thanks!

greg k-h

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 8/8] staging: use eth_hw_addr_set() in orphan drivers
  2021-10-19 17:12 ` [PATCH 8/8] staging: use eth_hw_addr_set() in orphan drivers Jakub Kicinski
@ 2021-10-20 16:53   ` Kees Cook
  0 siblings, 0 replies; 16+ messages in thread
From: Kees Cook @ 2021-10-20 16:53 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: gregkh, linux-staging

On Tue, Oct 19, 2021 at 10:12:43AM -0700, Jakub Kicinski wrote:
> 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.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Reviewed-by: Kees Cook <keescook@chromium.org>

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 7/8] staging: rtl: use eth_hw_addr_set()
  2021-10-19 17:12 ` [PATCH 7/8] staging: rtl: " Jakub Kicinski
@ 2021-11-03 11:29   ` Dan Carpenter
  2021-11-03 13:36     ` Jakub Kicinski
  0 siblings, 1 reply; 16+ messages in thread
From: Dan Carpenter @ 2021-11-03 11:29 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: gregkh, linux-staging, knv418, jiapeng.chong, ojaswin98, arnd,
	lee.jones, clrrm, fabioaiuto83, hdegoede, ross.schm.dev,
	insafonov

On Tue, Oct 19, 2021 at 10:12:42AM -0700, Jakub Kicinski wrote:
> diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
> index cfeaa9c1542f..7f9dee42a04d 100644
> --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
> +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
> @@ -360,11 +360,14 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev)
>  		 priv->eeprom_CustomerID);
>  
>  	if (!priv->AutoloadFailFlag) {
> +		u8 addr[ETH_ALEN];
> +
>  		for (i = 0; i < 6; i += 2) {
>  			usValue = rtl92e_eeprom_read(dev,
>  				 (EEPROM_NODE_ADDRESS_BYTE_0 + i) >> 1);
> -			*(u16 *)(&dev->dev_addr[i]) = usValue;
> +			*(u16 *)(&addr[i]) = usValue;

No this doesn't work.  It writes 2 bytes instead of one so it will
write one element beyond the end of addr[].  It doesn't work at all on
little endian systems.

I'm not sure what's going on here or how to fix it but array overflows
are always bad.

>  		}
> +		eth_hw_addr_set(dev, addr);
>  	} else {
>  		eth_hw_addr_set(dev, bMac_Tmp_Addr);
>  	}
> diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c
> index f75a12543781..d7630f02a910 100644
> --- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c
> +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c
> @@ -184,7 +184,7 @@ void rtl92e_cam_restore(struct net_device *dev)
>  		if (priv->rtllib->iw_mode == IW_MODE_ADHOC) {
>  			rtl92e_set_key(dev, 4, 0,
>  				       priv->rtllib->pairwise_key_type,
> -				       (u8 *)dev->dev_addr, 0,
> +				       (const u8 *)dev->dev_addr, 0,
>  				       (u32 *)(&priv->rtllib->swcamtable[4].key_buf[0]));
>  		} else {
>  			rtl92e_set_key(dev, 4, 0,
> @@ -197,7 +197,7 @@ void rtl92e_cam_restore(struct net_device *dev)
>  		if (priv->rtllib->iw_mode == IW_MODE_ADHOC) {
>  			rtl92e_set_key(dev, 4, 0,
>  				       priv->rtllib->pairwise_key_type,
> -				       (u8 *)dev->dev_addr, 0,
> +				       (const u8 *)dev->dev_addr, 0,
>  				       (u32 *)(&priv->rtllib->swcamtable[4].key_buf[0]));
>  		} else {
>  			rtl92e_set_key(dev, 4, 0,
> diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h
> index 4013107cd93a..14ca00a2789b 100644
> --- a/drivers/staging/rtl8192u/r8192U.h
> +++ b/drivers/staging/rtl8192u/r8192U.h
> @@ -1114,6 +1114,7 @@ void rtl8192_set_rxconf(struct net_device *dev);
>  void rtl819xusb_beacon_tx(struct net_device *dev, u16 tx_rate);
>  
>  void EnableHWSecurityConfig8192(struct net_device *dev);
> -void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, u8 *MacAddr, u8 DefaultKey, u32 *KeyContent);
> +void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType,
> +	    const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent);
>  
>  #endif
> diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
> index 3718d72e217e..cfbd9d79baa7 100644
> --- a/drivers/staging/rtl8192u/r8192U_core.c
> +++ b/drivers/staging/rtl8192u/r8192U_core.c
> @@ -2300,12 +2300,15 @@ static int rtl8192_read_eeprom_info(struct net_device *dev)
>  	/* set channelplan from eeprom */
>  	priv->ChannelPlan = priv->eeprom_ChannelPlan;
>  	if (bLoad_From_EEPOM) {
> +		u8 addr[ETH_ALEN];
> +
>  		for (i = 0; i < 6; i += 2) {
>  			ret = eprom_read(dev, (u16)((EEPROM_NODE_ADDRESS_BYTE_0 + i) >> 1));
>  			if (ret < 0)
>  				return ret;
> -			*(u16 *)(&dev->dev_addr[i]) = (u16)ret;
> +			*(u16 *)(&addr[i]) = (u16)ret;

Same thing here.

>  		}
> +		eth_hw_addr_set(dev, addr);
>  	} else {
>  		eth_hw_addr_set(dev, bMac_Tmp_Addr);
>  		/* should I set IDR0 here? */

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 7/8] staging: rtl: use eth_hw_addr_set()
  2021-11-03 11:29   ` Dan Carpenter
@ 2021-11-03 13:36     ` Jakub Kicinski
  2021-11-03 14:08       ` Dan Carpenter
  0 siblings, 1 reply; 16+ messages in thread
From: Jakub Kicinski @ 2021-11-03 13:36 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: gregkh, linux-staging, knv418, jiapeng.chong, ojaswin98, arnd,
	lee.jones, clrrm, fabioaiuto83, hdegoede, ross.schm.dev,
	insafonov

On Wed, 3 Nov 2021 14:29:06 +0300 Dan Carpenter wrote:
> >  	if (!priv->AutoloadFailFlag) {
> > +		u8 addr[ETH_ALEN];
> > +
> >  		for (i = 0; i < 6; i += 2) {
> >  			usValue = rtl92e_eeprom_read(dev,
> >  				 (EEPROM_NODE_ADDRESS_BYTE_0 + i) >> 1);
> > -			*(u16 *)(&dev->dev_addr[i]) = usValue;
> > +			*(u16 *)(&addr[i]) = usValue;  
> 
> No this doesn't work.  It writes 2 bytes instead of one so it will
> write one element beyond the end of addr[]. 

But the index moves by 2, IOW loop is only executed for i = 0, 2, 4.

> It doesn't work at all on little endian systems.

Indeed.

> I'm not sure what's going on here or how to fix it but array overflows
> are always bad.

Same :(

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 7/8] staging: rtl: use eth_hw_addr_set()
  2021-11-03 13:36     ` Jakub Kicinski
@ 2021-11-03 14:08       ` Dan Carpenter
  0 siblings, 0 replies; 16+ messages in thread
From: Dan Carpenter @ 2021-11-03 14:08 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: gregkh, linux-staging, knv418, jiapeng.chong, ojaswin98, arnd,
	lee.jones, clrrm, fabioaiuto83, hdegoede, ross.schm.dev,
	insafonov

On Wed, Nov 03, 2021 at 06:36:24AM -0700, Jakub Kicinski wrote:
> On Wed, 3 Nov 2021 14:29:06 +0300 Dan Carpenter wrote:
> > >  	if (!priv->AutoloadFailFlag) {
> > > +		u8 addr[ETH_ALEN];
> > > +
> > >  		for (i = 0; i < 6; i += 2) {
> > >  			usValue = rtl92e_eeprom_read(dev,
> > >  				 (EEPROM_NODE_ADDRESS_BYTE_0 + i) >> 1);
> > > -			*(u16 *)(&dev->dev_addr[i]) = usValue;
> > > +			*(u16 *)(&addr[i]) = usValue;  
> > 
> > No this doesn't work.  It writes 2 bytes instead of one so it will
> > write one element beyond the end of addr[]. 
> 
> But the index moves by 2, IOW loop is only executed for i = 0, 2, 4.

Ah, right.  I missed that.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-11-03 14:16 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-19 17:12 [PATCH 0/8] staging: prepare for const netdev->dev_addr Jakub Kicinski
2021-10-19 17:12 ` [PATCH 1/8] staging: use eth_hw_addr_set() Jakub Kicinski
2021-10-19 17:12 ` [PATCH 2/8] staging: use eth_hw_addr_set() instead of ether_addr_copy() Jakub Kicinski
2021-10-19 17:12 ` [PATCH 3/8] staging: use eth_hw_addr_set() for dev->addr_len cases Jakub Kicinski
2021-10-19 17:12 ` [PATCH 4/8] staging: qlge: use eth_hw_addr_set() Jakub Kicinski
2021-10-19 17:12 ` [PATCH 5/8] staging: rtl8712: prepare for const netdev->dev_addr Jakub Kicinski
2021-10-19 17:12 ` [PATCH 6/8] staging: unisys: use eth_hw_addr_set() Jakub Kicinski
2021-10-19 17:12 ` [PATCH 7/8] staging: rtl: " Jakub Kicinski
2021-11-03 11:29   ` Dan Carpenter
2021-11-03 13:36     ` Jakub Kicinski
2021-11-03 14:08       ` Dan Carpenter
2021-10-19 17:12 ` [PATCH 8/8] staging: use eth_hw_addr_set() in orphan drivers Jakub Kicinski
2021-10-20 16:53   ` Kees Cook
2021-10-19 17:34 ` [PATCH 0/8] staging: prepare for const netdev->dev_addr Greg KH
2021-10-19 18:01   ` Jakub Kicinski
2021-10-19 18:15     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).