Skip to contentSkip to conversation

staging: rtl8712: Use ether_addr_copy() instead of memcpy()

PATCH Superseded Jagan Teki 3 participants 3 messages May 17, 2015 – May 18, 2015 Staging

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jagan Teki

author
#0 lore raw

PATCH 1/1 staging: rtl8712: Use ether_addr_copy() instead of memcpy()

This patch fixes to use ether_addr_copy() instead of memcpy()

Encounter this by applying checkpatch.pl against this file:
WARNING: Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)

Cc Greg Kroah-Hartman <[email protected]>
Cc Larry Finger <[email protected]>
Cc Florian Schilhabel <[email protected]>
---
 drivers/staging/rtl8712/os_intfs.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/rtl8712/os_intfs.c +5 -5
index 6e776e5..0d27df6 100644
@@ -181,7 +181,7 @@ static int r871x_net_set_mac_address(struct net_device *pnetdev, void *p)
 	struct sockaddr *addr = p;
 
 	if (padapter->bup == false)
-		memcpy(pnetdev->dev_addr, addr->sa_data, ETH_ALEN);
+		ether_addr_copy(pnetdev->dev_addr, addr->sa_data);
 	return 0;
 }
 
@@ -395,8 +395,8 @@ static int netdev_open(struct net_device *pnetdev)
 			goto netdev_open_error;
 		if (r8712_initmac == NULL)
 			/* Use the mac address stored in the Efuse */
-			memcpy(pnetdev->dev_addr,
-				padapter->eeprompriv.mac_addr, ETH_ALEN);
+			ether_addr_copy(pnetdev->dev_addr,
+					padapter->eeprompriv.mac_addr);
 		else {
 			/* We have to inform f/w to use user-supplied MAC
 			 * address.
@@ -412,8 +412,8 @@ static int netdev_open(struct net_device *pnetdev)
 			 * the eeprompriv.mac_addr should store the mac which
 			 * users specify.
 			 */
-			memcpy(padapter->eeprompriv.mac_addr,
-				pnetdev->dev_addr, ETH_ALEN);
+			ether_addr_copy(padapter->eeprompriv.mac_addr,
+					pnetdev->dev_addr);
 		}
 		if (start_drv_threads(padapter) != _SUCCESS)
 			goto netdev_open_error;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 6 lines · Jagan Teki

This patch fixes to use ether_addr_copy() instead of memcpy()

Encounter this by applying checkpatch.pl against this file:
WARNING: Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)

Quoted 7 lines
Cc Greg Kroah-Hartman <[email protected]>
Cc Larry Finger <[email protected]>
Cc Florian Schilhabel <[email protected]>
---
 drivers/staging/rtl8712/os_intfs.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

You need to prove that the addresses are aligned, please do so in the changelog entry.

#2 lore raw
In reply to Jagan Teki
Quoted 11 lines · Jagan Teki

This patch fixes to use ether_addr_copy() instead of memcpy()

Encounter this by applying checkpatch.pl against this file:
WARNING: Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)

Cc Greg Kroah-Hartman <[email protected]>
Cc Larry Finger <[email protected]>
Cc Florian Schilhabel <[email protected]>

---

Can you assure us that you have carefully checked the the source address of addr->sa_data and padapter->eeprompriv.mac_addr are suitably aligned? At a minimum, have you tested this change on real hardware?

Larry

Quoted 39 lines
  drivers/staging/rtl8712/os_intfs.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/rtl8712/os_intfs.c +5 -5
index 6e776e5..0d27df6 100644
@@ -181,7 +181,7 @@ static int r871x_net_set_mac_address(struct net_device *pnetdev, void *p)
  	struct sockaddr *addr = p;
 
  	if (padapter->bup == false)
-		memcpy(pnetdev->dev_addr, addr->sa_data, ETH_ALEN);
+		ether_addr_copy(pnetdev->dev_addr, addr->sa_data);
  	return 0;
  }
 
@@ -395,8 +395,8 @@ static int netdev_open(struct net_device *pnetdev)
  			goto netdev_open_error;
  		if (r8712_initmac == NULL)
  			/* Use the mac address stored in the Efuse */
-			memcpy(pnetdev->dev_addr,
-				padapter->eeprompriv.mac_addr, ETH_ALEN);
+			ether_addr_copy(pnetdev->dev_addr,
+					padapter->eeprompriv.mac_addr);
  		else {
  			/* We have to inform f/w to use user-supplied MAC
  			 * address.
@@ -412,8 +412,8 @@ static int netdev_open(struct net_device *pnetdev)
  			 * the eeprompriv.mac_addr should store the mac which
  			 * users specify.
  			 */
-			memcpy(padapter->eeprompriv.mac_addr,
-				pnetdev->dev_addr, ETH_ALEN);
+			ether_addr_copy(padapter->eeprompriv.mac_addr,
+					pnetdev->dev_addr);
  		}
  		if (start_drv_threads(padapter) != _SUCCESS)
  			goto netdev_open_error;