All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lijun Pan <ljp@linux.ibm.com>
To: netdev@vger.kernel.org
Cc: Lijun Pan <ljp@linux.ibm.com>, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net] ibmvnic: no need to update adapter->mac_addr before it completes
Date: Tue, 20 Oct 2020 18:28:12 -0500	[thread overview]
Message-ID: <20201020232812.46498-1-ljp@linux.ibm.com> (raw)

Jakub Kicinski brought up a concern in ibmvnic_set_mac().
ibmvnic_set_mac() does this:

	ether_addr_copy(adapter->mac_addr, addr->sa_data);
	if (adapter->state != VNIC_PROBED)
		rc = __ibmvnic_set_mac(netdev, addr->sa_data);

So if state == VNIC_PROBED, the user can assign an invalid address to
adapter->mac_addr, and ibmvnic_set_mac() will still return 0.

The fix is to not update adapter->mac_addr in ibmvnic_set_mac
and the error path of __ibmvnic_set_mac, and to update adpater->mac_addr
in handle_change_mac_rsp after the change mac request is completed in
VIOS.

Fixes: 62740e97881c ("net/ibmvnic: Update MAC address settings after adapter reset")
Cc: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Lijun Pan <ljp@linux.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 4dd3625a4fbc..c4c2b0e453fc 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1817,7 +1817,6 @@ static int __ibmvnic_set_mac(struct net_device *netdev, u8 *dev_addr)
 	mutex_unlock(&adapter->fw_lock);
 	return 0;
 err:
-	ether_addr_copy(adapter->mac_addr, netdev->dev_addr);
 	return rc;
 }
 
@@ -1828,7 +1827,6 @@ static int ibmvnic_set_mac(struct net_device *netdev, void *p)
 	int rc;
 
 	rc = 0;
-	ether_addr_copy(adapter->mac_addr, addr->sa_data);
 	if (adapter->state != VNIC_PROBED)
 		rc = __ibmvnic_set_mac(netdev, addr->sa_data);
 
-- 
2.23.0


             reply	other threads:[~2020-10-20 23:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-20 23:28 Lijun Pan [this message]
2020-10-20 23:48 ` [PATCH net] ibmvnic: no need to update adapter->mac_addr before it completes Jakub Kicinski

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=20201020232812.46498-1-ljp@linux.ibm.com \
    --to=ljp@linux.ibm.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.