linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jon Mason <jon.mason@broadcom.com>
To: David Miller <davem@davemloft.net>
Cc: rafal@milecki.pl, bcm-kernel-feedback-list@broadcom.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Hari Vyas <hariv@broadcom.com>
Subject: [PATCH net v5 2/2] net: ethernet: bgmac: mac address change bug
Date: Thu,  2 Mar 2017 17:59:57 -0500	[thread overview]
Message-ID: <1488495597-5835-3-git-send-email-jon.mason@broadcom.com> (raw)
In-Reply-To: <1488495597-5835-1-git-send-email-jon.mason@broadcom.com>

From: Hari Vyas <hariv@broadcom.com>

ndo_set_mac_address() passes struct sockaddr * as 2nd parameter to
bgmac_set_mac_address() but code assumed u8 *.  This caused two bytes
chopping and the wrong mac address was configured.

Signed-off-by: Hari Vyas <hariv@broadcom.com>
Signed-off-by: Jon Mason <jon.mason@broadcom.com>
Fixes: 4e209001b86 ("bgmac: write mac address to hardware in ndo_set_mac_address")
---
 drivers/net/ethernet/broadcom/bgmac.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
index 4150467..fd66fca 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -1223,12 +1223,16 @@ static netdev_tx_t bgmac_start_xmit(struct sk_buff *skb,
 static int bgmac_set_mac_address(struct net_device *net_dev, void *addr)
 {
 	struct bgmac *bgmac = netdev_priv(net_dev);
+	struct sockaddr *sa = addr;
 	int ret;
 
 	ret = eth_prepare_mac_addr_change(net_dev, addr);
 	if (ret < 0)
 		return ret;
-	bgmac_write_mac_address(bgmac, (u8 *)addr);
+
+	ether_addr_copy(net_dev->dev_addr, sa->sa_data);
+	bgmac_write_mac_address(bgmac, net_dev->dev_addr);
+
 	eth_commit_mac_addr_change(net_dev, addr);
 	return 0;
 }
-- 
2.7.4

  parent reply	other threads:[~2017-03-02 23:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-02 22:59 [PATCH net v5 0/2] net: ethernet: bgmac: bug fixes Jon Mason
2017-03-02 22:59 ` [PATCH net v5 1/2] net: ethernet: bgmac: init sequence bug Jon Mason
2017-03-02 22:59 ` Jon Mason [this message]
2017-03-03 17:44 ` [PATCH net v5 0/2] net: ethernet: bgmac: bug fixes David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1488495597-5835-3-git-send-email-jon.mason@broadcom.com \
    --to=jon.mason@broadcom.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=hariv@broadcom.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rafal@milecki.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).