net/bnxt: fix crash
Fix use of local variable to avoid segfault.
cnt was incorrectly tested and decremented in the loop that removes
a VLAN from the table.
Fixes: 36735a932c
("net/bnxt: support set VF QOS and MAC anti spoof")
Signed-off-by: Stephen Hurd <stephen.hurd@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
This commit is contained in:
parent
564be0240e
commit
31ded672aa
@ -473,7 +473,9 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
|
|||||||
|
|
||||||
for (i = 0; vf_mask; i++, vf_mask >>= 1) {
|
for (i = 0; vf_mask; i++, vf_mask >>= 1) {
|
||||||
cnt = bp->pf.vf_info[i].vlan_count;
|
cnt = bp->pf.vf_info[i].vlan_count;
|
||||||
if (vf_mask & 1) {
|
if ((vf_mask & 1) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (bp->pf.vf_info[i].vlan_table == NULL) {
|
if (bp->pf.vf_info[i].vlan_table == NULL) {
|
||||||
rc = -1;
|
rc = -1;
|
||||||
continue;
|
continue;
|
||||||
@ -482,8 +484,7 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
|
|||||||
/* First, search for a duplicate... */
|
/* First, search for a duplicate... */
|
||||||
for (j = 0; j < cnt; j++) {
|
for (j = 0; j < cnt; j++) {
|
||||||
if (rte_be_to_cpu_16(
|
if (rte_be_to_cpu_16(
|
||||||
bp->pf.vf_info[i].vlan_table[j].vid) ==
|
bp->pf.vf_info[i].vlan_table[j].vid) == vlan)
|
||||||
vlan)
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (j == cnt) {
|
if (j == cnt) {
|
||||||
@ -494,12 +495,12 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
|
|||||||
"VF %d VLAN table is full\n",
|
"VF %d VLAN table is full\n",
|
||||||
i);
|
i);
|
||||||
RTE_LOG(ERR, PMD,
|
RTE_LOG(ERR, PMD,
|
||||||
"cannot add VLAN %u\n",
|
"cannot add VLAN %u\n", vlan);
|
||||||
vlan);
|
|
||||||
rc = -1;
|
rc = -1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* cnt is one less than vlan_count */
|
||||||
cnt = bp->pf.vf_info[i].vlan_count++;
|
cnt = bp->pf.vf_info[i].vlan_count++;
|
||||||
/*
|
/*
|
||||||
* And finally, add to the
|
* And finally, add to the
|
||||||
@ -511,24 +512,20 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
|
|||||||
ve->vid = rte_cpu_to_be_16(vlan);
|
ve->vid = rte_cpu_to_be_16(vlan);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (j = 0; cnt; j++) {
|
for (j = 0; j < cnt; j++) {
|
||||||
if (rte_be_to_cpu_16(
|
if (rte_be_to_cpu_16(
|
||||||
bp->pf.vf_info[i].vlan_table[j].vid) !=
|
bp->pf.vf_info[i].vlan_table[j].vid) != vlan)
|
||||||
vlan)
|
|
||||||
continue;
|
continue;
|
||||||
memmove(
|
memmove(&bp->pf.vf_info[i].vlan_table[j],
|
||||||
&bp->pf.vf_info[i].vlan_table[j],
|
|
||||||
&bp->pf.vf_info[i].vlan_table[j + 1],
|
&bp->pf.vf_info[i].vlan_table[j + 1],
|
||||||
getpagesize() -
|
getpagesize() - ((j + 1) *
|
||||||
((j + 1) *
|
|
||||||
sizeof(struct bnxt_vlan_table_entry)));
|
sizeof(struct bnxt_vlan_table_entry)));
|
||||||
j--;
|
j--;
|
||||||
cnt = bp->pf.vf_info[i].vlan_count--;
|
cnt = --bp->pf.vf_info[i].vlan_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rte_pmd_bnxt_set_vf_vlan_anti_spoof(dev->data->port_id,
|
rte_pmd_bnxt_set_vf_vlan_anti_spoof(dev->data->port_id, i,
|
||||||
i, bp->pf.vf_info[i].vlan_spoof_en);
|
bp->pf.vf_info[i].vlan_spoof_en);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
Loading…
Reference in New Issue
Block a user