netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers:ethernet:davinci_emac.c:Fixes flaw in mac address handling.
@ 2014-10-02  2:32 Michael Welling
  2014-10-03 20:03 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Welling @ 2014-10-02  2:32 UTC (permalink / raw)
  To: davem, tony, netdev, linux-kernel; +Cc: Michael Welling

The code currently checks the mac_addr variable that is clearly
zero'd out during allocation.

Further code is added to bring the mac_addr from the partial pdata.

Signed-off-by: Michael Welling <mwelling@ieee.org>
---
 drivers/net/ethernet/ti/davinci_emac.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index ea71251..e06f97c 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -1804,11 +1804,9 @@ davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv)
 	np = pdev->dev.of_node;
 	pdata->version = EMAC_VERSION_2;
 
-	if (!is_valid_ether_addr(pdata->mac_addr)) {
-		mac_addr = of_get_mac_address(np);
-		if (mac_addr)
-			memcpy(pdata->mac_addr, mac_addr, ETH_ALEN);
-	}
+	mac_addr = of_get_mac_address(np);
+	if (mac_addr)
+		memcpy(pdata->mac_addr, mac_addr, ETH_ALEN);
 
 	of_property_read_u32(np, "ti,davinci-ctrl-reg-offset",
 			     &pdata->ctrl_reg_offset);
@@ -1834,6 +1832,8 @@ davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv)
 	if (auxdata) {
 		pdata->interrupt_enable = auxdata->interrupt_enable;
 		pdata->interrupt_disable = auxdata->interrupt_disable;
+		if (is_valid_ether_addr(auxdata->mac_addr))
+			memcpy(pdata->mac_addr, auxdata->mac_addr, ETH_ALEN);
 	}
 
 	match = of_match_device(davinci_emac_of_match, &pdev->dev);
-- 
1.7.9.5

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

* Re: [PATCH] drivers:ethernet:davinci_emac.c:Fixes flaw in mac address handling.
  2014-10-02  2:32 [PATCH] drivers:ethernet:davinci_emac.c:Fixes flaw in mac address handling Michael Welling
@ 2014-10-03 20:03 ` David Miller
  2014-10-03 20:43   ` Michael Welling
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2014-10-03 20:03 UTC (permalink / raw)
  To: mwelling; +Cc: tony, netdev, linux-kernel

From: Michael Welling <mwelling@ieee.org>
Date: Wed,  1 Oct 2014 21:32:05 -0500

> The code currently checks the mac_addr variable that is clearly
> zero'd out during allocation.
> 
> Further code is added to bring the mac_addr from the partial pdata.
> 
> Signed-off-by: Michael Welling <mwelling@ieee.org>

I don't see anyone specifying a MAC address in the partial pdata,
so better to just delete that field.

Even if people did, I am not so sure that the partial pdata should
unconditionally trump an OF provided MAC address.

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

* Re: [PATCH] drivers:ethernet:davinci_emac.c:Fixes flaw in mac address handling.
  2014-10-03 20:03 ` David Miller
@ 2014-10-03 20:43   ` Michael Welling
  2014-10-03 21:55     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Welling @ 2014-10-03 20:43 UTC (permalink / raw)
  To: David Miller; +Cc: tony, netdev, linux-kernel

On Fri, Oct 03, 2014 at 01:03:05PM -0700, David Miller wrote:
> From: Michael Welling <mwelling@ieee.org>
> Date: Wed,  1 Oct 2014 21:32:05 -0500
> 
> > The code currently checks the mac_addr variable that is clearly
> > zero'd out during allocation.
> > 
> > Further code is added to bring the mac_addr from the partial pdata.
> > 
> > Signed-off-by: Michael Welling <mwelling@ieee.org>
> 
> I don't see anyone specifying a MAC address in the partial pdata,
> so better to just delete that field.
> 
> Even if people did, I am not so sure that the partial pdata should
> unconditionally trump an OF provided MAC address.

So should I just leave the code for handling the mac_addr field from the
partial pdata out or make it such that the mac_addr field is overriden 
if specified from the devicetree?

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

* Re: [PATCH] drivers:ethernet:davinci_emac.c:Fixes flaw in mac address handling.
  2014-10-03 20:43   ` Michael Welling
@ 2014-10-03 21:55     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2014-10-03 21:55 UTC (permalink / raw)
  To: mwelling; +Cc: tony, netdev, linux-kernel

From: Michael Welling <mwelling@ieee.org>
Date: Fri, 3 Oct 2014 15:43:59 -0500

> On Fri, Oct 03, 2014 at 01:03:05PM -0700, David Miller wrote:
>> From: Michael Welling <mwelling@ieee.org>
>> Date: Wed,  1 Oct 2014 21:32:05 -0500
>> 
>> > The code currently checks the mac_addr variable that is clearly
>> > zero'd out during allocation.
>> > 
>> > Further code is added to bring the mac_addr from the partial pdata.
>> > 
>> > Signed-off-by: Michael Welling <mwelling@ieee.org>
>> 
>> I don't see anyone specifying a MAC address in the partial pdata,
>> so better to just delete that field.
>> 
>> Even if people did, I am not so sure that the partial pdata should
>> unconditionally trump an OF provided MAC address.
> 
> So should I just leave the code for handling the mac_addr field from the
> partial pdata out or make it such that the mac_addr field is overriden 
> if specified from the devicetree?

I'm saying the partial pdata mac_addr is completely unused and should
be removed.

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

end of thread, other threads:[~2014-10-03 21:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-02  2:32 [PATCH] drivers:ethernet:davinci_emac.c:Fixes flaw in mac address handling Michael Welling
2014-10-03 20:03 ` David Miller
2014-10-03 20:43   ` Michael Welling
2014-10-03 21:55     ` David Miller

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