Patchwork [net,5/9] qlcnic: Fix panic while setting VF's MAC address

login
register
mail settings
Submitter Sucheta Chakraborty
Date July 19, 2013, 8:56 p.m.
Message ID <1374267394-27697-6-git-send-email-sucheta.chakraborty@qlogic.com>
Download mbox | patch
Permalink /patch/260356/
State Accepted
Delegated to: David Miller
Headers show

Comments

Sucheta Chakraborty - July 19, 2013, 8:56 p.m.
From: Manish Chopra <manish.chopra@qlogic.com>

o "qlcnic_sriov" structure pointer should be accessed only
  when SR-IOV is enabled. Access this pointer after SR-IOV
  PF check.

Signed-off-by: Manish Chopra <manish.chopra@qlogic.com>
Signed-off-by: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com>
---
 .../net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c   |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

Patch

diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c
index ee0c1d3..b9b88f3 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c
@@ -1621,13 +1621,15 @@  int qlcnic_sriov_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
 {
 	struct qlcnic_adapter *adapter = netdev_priv(netdev);
 	struct qlcnic_sriov *sriov = adapter->ahw->sriov;
-	int i, num_vfs = sriov->num_vfs;
+	int i, num_vfs;
 	struct qlcnic_vf_info *vf_info;
 	u8 *curr_mac;
 
 	if (!qlcnic_sriov_pf_check(adapter))
 		return -EOPNOTSUPP;
 
+	num_vfs = sriov->num_vfs;
+
 	if (!is_valid_ether_addr(mac) || vf >= num_vfs)
 		return -EINVAL;