mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] net: only use ethaddrs registered with device node on that device
@ 2018-11-07 20:22 Lucas Stach
  2018-11-08  7:54 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Lucas Stach @ 2018-11-07 20:22 UTC (permalink / raw)
  To: barebox

If an ethaddr is registered with a device node the ethid is set
to 0 via the struct initialization. Now if a device without a node
(for eaxample a USB network adapter) with ethid 0 looks up the
ethaddr it will wrongly get that address assigned, as the ethid
matches.

Avoid this by setting the ethid to something that no device will
ever use when the addr is registered via a device node.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 net/eth.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/eth.c b/net/eth.c
index 9dc44119528e..badd18343349 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -150,6 +150,7 @@ void of_eth_register_ethaddr(struct device_node *node, const char *ethaddr)
 
 	addr = xzalloc(sizeof(*addr));
 	addr->node = node;
+	addr->ethid = -1;
 	memcpy(addr->ethaddr, ethaddr, ETH_ALEN);
 	list_add_tail(&addr->list, &ethaddr_list);
 }
-- 
2.19.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] net: only use ethaddrs registered with device node on that device
  2018-11-07 20:22 [PATCH] net: only use ethaddrs registered with device node on that device Lucas Stach
@ 2018-11-08  7:54 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2018-11-08  7:54 UTC (permalink / raw)
  To: Lucas Stach; +Cc: barebox

On Wed, Nov 07, 2018 at 09:22:15PM +0100, Lucas Stach wrote:
> If an ethaddr is registered with a device node the ethid is set
> to 0 via the struct initialization. Now if a device without a node
> (for eaxample a USB network adapter) with ethid 0 looks up the
> ethaddr it will wrongly get that address assigned, as the ethid
> matches.
> 
> Avoid this by setting the ethid to something that no device will
> ever use when the addr is registered via a device node.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
>  net/eth.c | 1 +
>  1 file changed, 1 insertion(+)

Applied, thanks

Sascha

> 
> diff --git a/net/eth.c b/net/eth.c
> index 9dc44119528e..badd18343349 100644
> --- a/net/eth.c
> +++ b/net/eth.c
> @@ -150,6 +150,7 @@ void of_eth_register_ethaddr(struct device_node *node, const char *ethaddr)
>  
>  	addr = xzalloc(sizeof(*addr));
>  	addr->node = node;
> +	addr->ethid = -1;
>  	memcpy(addr->ethaddr, ethaddr, ETH_ALEN);
>  	list_add_tail(&addr->list, &ethaddr_list);
>  }
> -- 
> 2.19.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2018-11-08  7:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-07 20:22 [PATCH] net: only use ethaddrs registered with device node on that device Lucas Stach
2018-11-08  7:54 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox