When adding an ethertype filter on an HTN NIC, a TCAM index is allocated
before the firmware command is sent. If the command fails, the index is
never freed, leaking a dynamic TCAM slot and eventually exhausting the
dynamic TCAM pool. Free the index on the error path.
Fixes: efa3b9b36fc7 ("net/hinic3: add flow control and filters")
Cc: [email protected]
Signed-off-by: Jiacheng Ye <[email protected]>
---
drivers/net/hinic3/hinic3_fdir.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/hinic3/hinic3_fdir.c b/drivers/net/hinic3/hinic3_fdir.c
index 71d50a3d22..95ce7cfe16 100644
--- a/drivers/net/hinic3/hinic3_fdir.c
+++ b/drivers/net/hinic3/hinic3_fdir.c
@@ -1001,6 +1001,9 @@ hinic3_set_fdir_ethertype_filter(void *hwdev, uint8_t
pkt_type, void *filter, ui
PMD_DRV_LOG(ERR,
"set fdir ethertype rule failed, err: %d, status:
0x%x, out size: 0x%x, func_id %d",
err, ethertype_cmd.head.status, out_size,
ethertype_cmd.func_id);
+ if ((hinic3_get_driver_feature(nic_dev) & NIC_F_HTN_FDIR) != 0
&& en != 0)
+ hinic3_tcam_index_free(nic_dev,
HINIC3_TCAM_GET_INDEX_IN_BLOCK(index),
+ HINIC3_TCAM_GET_DYNAMIC_BLOCK_INDEX(index));
return -EIO;
}
if ((hinic3_get_driver_feature(nic_dev) & NIC_F_HTN_FDIR) != 0) {
--
2.33.0