diff mbox series

[v2,1/1] r8152: sync sa_family with the media type of network device

Message ID 20190422050344.24513-1-crag0715@gmail.com (mailing list archive)
State Mainlined
Commit a6cbcb7793596eb8b8dd9564e534c5cfc0a4fdbc
Headers show
Series [v2,1/1] r8152: sync sa_family with the media type of network device | expand

Commit Message

Crag Wang April 22, 2019, 5:03 a.m. UTC
From: "Crag.Wang" <crag.wang@dell.com>

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.

Signed-off-by: Crag.Wang <crag.wang@dell.com>
---
 drivers/net/usb/r8152.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jakub Kicinski April 22, 2019, 8:39 p.m. UTC | #1
On Mon, 22 Apr 2019 13:03:43 +0800, crag0715@gmail.com wrote:
> From: "Crag.Wang" <crag.wang@dell.com>
> 
> 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.
> 
> Signed-off-by: Crag.Wang <crag.wang@dell.com>

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 :)

Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>

> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
> index 4c63b40d5e00..41fb39ce69c9 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
> @@ -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 {
Limonciello, Mario April 22, 2019, 9:29 p.m. UTC | #2
> -----Original Message-----
> From: crag0715@gmail.com <crag0715@gmail.com>
> Sent: Monday, April 22, 2019 12:04 AM
> To: linux-usb@vger.kernel.org; netdev@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org; hayeswang@realtek.com; Limonciello, Mario;
> crag0715@gmail.com; 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
> 
> 
> [EXTERNAL EMAIL]
> 
> From: "Crag.Wang" <crag.wang@dell.com>
> 
> 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.

> 
> Signed-off-by: Crag.Wang <crag.wang@dell.com>
> ---
>  drivers/net/usb/r8152.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
> index 4c63b40d5e00..41fb39ce69c9 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
> @@ -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 {
> --
> 2.20.1

Reviewed-By: Mario Limonciello <mario.limonciello@dell.com>
Crag Wang April 23, 2019, 2:52 a.m. UTC | #3
On Tue, Apr 23, 2019 at 4:39 AM Jakub Kicinski
<jakub.kicinski@netronome.com> wrote:
>
> On Mon, 22 Apr 2019 13:03:43 +0800, crag0715@gmail.com wrote:
> > From: "Crag.Wang" <crag.wang@dell.com>
> >
> > 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.
> >
> > Signed-off-by: Crag.Wang <crag.wang@dell.com>
>
> 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 :)
>
> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
>
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
David Miller April 23, 2019, 5:15 a.m. UTC | #4
From: crag0715@gmail.com
Date: Mon, 22 Apr 2019 13:03:43 +0800

> From: "Crag.Wang" <crag.wang@dell.com>
> 
> 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.
> 
> Signed-off-by: Crag.Wang <crag.wang@dell.com>

Applied to net-next with Fixes: tag added.
diff mbox series

Patch

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 4c63b40d5e00..41fb39ce69c9 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -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 {