Commit b500350a authored by Andre Guedes's avatar Andre Guedes Committed by Jeff Kirsher

igc: Fix locking issue when retrieving NFC rules

Access to NFC rules stored in adapter->nfc_rule_list is protect by
adapter->nfc_rule_lock. The functions igc_ethtool_get_nfc_rule()
and igc_ethtool_get_nfc_rules() are missing to hold the lock while
accessing rule objects.
Signed-off-by: default avatarAndre Guedes <andre.guedes@intel.com>
Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent d3ba9e6f
......@@ -939,16 +939,18 @@ static int igc_ethtool_get_nfc_rule(struct igc_adapter *adapter,
cmd->data = IGC_MAX_RXNFC_RULES;
spin_lock(&adapter->nfc_rule_lock);
hlist_for_each_entry(rule, &adapter->nfc_rule_list, nfc_node) {
if (fsp->location <= rule->location)
break;
}
if (!rule || fsp->location != rule->location)
return -EINVAL;
goto out;
if (!rule->filter.match_flags)
return -EINVAL;
goto out;
fsp->flow_type = ETHER_FLOW;
fsp->ring_cookie = rule->action;
......@@ -976,7 +978,12 @@ static int igc_ethtool_get_nfc_rule(struct igc_adapter *adapter,
eth_broadcast_addr(fsp->m_u.ether_spec.h_source);
}
spin_unlock(&adapter->nfc_rule_lock);
return 0;
out:
spin_unlock(&adapter->nfc_rule_lock);
return -EINVAL;
}
static int igc_ethtool_get_nfc_rules(struct igc_adapter *adapter,
......@@ -988,13 +995,19 @@ static int igc_ethtool_get_nfc_rules(struct igc_adapter *adapter,
cmd->data = IGC_MAX_RXNFC_RULES;
spin_lock(&adapter->nfc_rule_lock);
hlist_for_each_entry(rule, &adapter->nfc_rule_list, nfc_node) {
if (cnt == cmd->rule_cnt)
if (cnt == cmd->rule_cnt) {
spin_unlock(&adapter->nfc_rule_lock);
return -EMSGSIZE;
}
rule_locs[cnt] = rule->location;
cnt++;
}
spin_unlock(&adapter->nfc_rule_lock);
cmd->rule_cnt = cnt;
return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment