Commit a16edabe7f744b2d7a97bba4d4bc95b6894fd592
Committed by
Joe Hershberger
1 parent
50dae85c71
Exists in
v2017.01-smarct4x
and in
30 other branches
net: eth: Clear MAC address in eth_pre_remove()
platdata->enetaddr was assigned to a value in dev_probe() last time. If we don't clear it, for dev_probe() at the second time, dm eth will end up treating it as a MAC address from ROM no matter where it came from originally (maybe env, ROM, or even random). Fix this by clearing platdata->enetaddr when removing an Ethernet device. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Showing 1 changed file with 5 additions and 0 deletions Side-by-side Diff
net/eth.c
... | ... | @@ -575,7 +575,12 @@ |
575 | 575 | |
576 | 576 | static int eth_pre_remove(struct udevice *dev) |
577 | 577 | { |
578 | + struct eth_pdata *pdata = dev->platdata; | |
579 | + | |
578 | 580 | eth_get_ops(dev)->stop(dev); |
581 | + | |
582 | + /* clear the MAC address */ | |
583 | + memset(pdata->enetaddr, 0, 6); | |
579 | 584 | |
580 | 585 | return 0; |
581 | 586 | } |