Skip to contentSkip to conversation

r8152: sync sa_family with the media type of network device

PATCH Applied [email protected] 4 participants 5 messages Apr 22, 2019 – Apr 23, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 r8152: sync sa_family with the media type of network device

From: "Crag.Wang" <[email protected]>

Without this patch the socket address family sporadically gets wrong value ends up the dev_set_mac_address() fails to set the desired MAC address.

---
 drivers/net/usb/r8152.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/usb/r8152.c +2 -0
index 4c63b40d5e00..41fb39ce69c9 100644
@@ -1225,6 +1225,8 @@ static int determine_ethernet_addr(struct r8152 *tp, struct sockaddr *sa)
 	struct net_device *dev = tp->netdev;
 	int ret;
 
+	sa->sa_family = dev->type;
+
 	if (tp->version == RTL_VER_01) {
 		ret = pla_ocp_read(tp, PLA_IDR, 8, sa->sa_data);
 	} else {
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · On Mon, 22 Apr 2019 13:03:43 +0800, [email protected] wrote:

From: "Crag.Wang" <[email protected]>

Without this patch the socket address family sporadically gets wrong value ends up the dev_set_mac_address() fails to set the desired MAC address.

Code looks reasonable. This must have been caused by:

Fixes 25766271e42f ("r8152: Refresh MAC address during USBDEVFS_RESET")

which is still in net-next. In the future please make sure you read:

https://www.kernel.org/doc/html/latest/networking/netdev-FAQ.html

In particular:

https://www.kernel.org/doc/html/latest/networking/netdev-FAQ.html#q-how-do-i-indicate-which-tree-net-vs-net-next-my-patch-should-be-in

To assure smooth flow of your patches into the tree :)

Quoted 13 lines
drivers/net/usb/r8152.c +2 -0
index 4c63b40d5e00..41fb39ce69c9 100644
@@ -1225,6 +1225,8 @@ static int determine_ethernet_addr(struct r8152 *tp, struct sockaddr *sa)
 	struct net_device *dev = tp->netdev;
 	int ret;
 
+	sa->sa_family = dev->type;
+
 	if (tp->version == RTL_VER_01) {
 		ret = pla_ocp_read(tp, PLA_IDR, 8, sa->sa_data);
 	} else {
author
#2 lore raw
Quoted 18 lines · Jakub Kicinski
Quoted 7 lines · On Mon, 22 Apr 2019 13:03:43 +0800, [email protected] wrote:

From: "Crag.Wang" <[email protected]>

Without this patch the socket address family sporadically gets wrong value ends up the dev_set_mac_address() fails to set the desired MAC address.

Code looks reasonable. This must have been caused by:

Fixes 25766271e42f ("r8152: Refresh MAC address during USBDEVFS_RESET")

which is still in net-next. In the future please make sure you read:

https://www.kernel.org/doc/html/latest/networking/netdev-FAQ.html

Quoted 8 lines

In particular:

https://www.kernel.org/doc/html/latest/networking/netdev-FAQ.html#q-how-do-i-indicate-which-tree-net-vs-net-next-my-patch-should-be-in

To assure smooth flow of your patches into the tree :)

Yes, patch is intended to fix 25766271e42f which is still in net-next.

It appears that prefix is desired in the subject. Thanks for sharing the info.

Crag

Reviewed-by on v2 1/1
#3 lore raw
In reply to [email protected]
Quoted 12 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Monday, April 22, 2019 12:04 AM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; Limonciello, Mario; [email protected]; Wang, Crag; David S. Miller; Simon Glass; Grant Grundler; Sean Paul; Chen7, David; Kai-Heng Feng; Gustavo A. R. Silva; Charles Hyde; Sebastian Andrzej Siewior; zhong jiang
Subject: [PATCH v2 1/1] r8152: sync sa_family with the media type of network device

Quoted 7 lines

[EXTERNAL EMAIL]

From: "Crag.Wang" <[email protected]>

Without this patch the socket address family sporadically gets wrong value ends up the dev_set_mac_address() fails to set the desired MAC address.

Ah yes, this is because of an uninitialized struct sockaddr, so random garbage. I didn't catch it during my testing, good catch.

Quoted 19 lines
---
 drivers/net/usb/r8152.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/usb/r8152.c +2 -0
index 4c63b40d5e00..41fb39ce69c9 100644
@@ -1225,6 +1225,8 @@ static int determine_ethernet_addr(struct r8152 *tp,
 struct sockaddr *sa)
 	struct net_device *dev = tp->netdev;
 	int ret;
 
+	sa->sa_family = dev->type;
+
 	if (tp->version == RTL_VER_01) {
 		ret = pla_ocp_read(tp, PLA_IDR, 8, sa->sa_data);
Quoted 3 lines

} else {
--
2.20.1