* [PATCH] net: hns3: Add error handling for VLAN filter hardware configuration
@ 2025-05-17 14:15 Wentao Liang
2025-05-19 15:30 ` Jijie Shao
0 siblings, 1 reply; 4+ messages in thread
From: Wentao Liang @ 2025-05-17 14:15 UTC (permalink / raw)
To: shenjian15, salil.mehta, shaojijie, andrew+netdev, davem,
edumazet, kuba, pabeni
Cc: horms, lanhao, wangpeiyang1, rosenp, liuyonglong, netdev,
linux-kernel, Wentao Liang, stable
The hclge_rm_vport_vlan_table() calls hclge_set_vlan_filter_hw() but does
not check the return value. This could lead to execution with potentially
invalid data. A proper implementation can be found in
hclge_add_vport_all_vlan_table().
Add error handling after calling hclge_set_vlan_filter_hw(). If
hclge_set_vlan_filter_hw() fails, log an error message via dev_err() and
return.
Fixes: c6075b193462 ("net: hns3: Record VF vlan tables")
Cc: stable@vger.kernel.org # v5.1
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
.../hisilicon/hns3/hns3pf/hclge_main.c | 20 +++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index db7845009252..5ab4c7f63766 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -10141,15 +10141,23 @@ static void hclge_rm_vport_vlan_table(struct hclge_vport *vport, u16 vlan_id,
{
struct hclge_vport_vlan_cfg *vlan, *tmp;
struct hclge_dev *hdev = vport->back;
+ int ret;
list_for_each_entry_safe(vlan, tmp, &vport->vlan_list, node) {
if (vlan->vlan_id == vlan_id) {
- if (is_write_tbl && vlan->hd_tbl_status)
- hclge_set_vlan_filter_hw(hdev,
- htons(ETH_P_8021Q),
- vport->vport_id,
- vlan_id,
- true);
+ if (is_write_tbl && vlan->hd_tbl_status) {
+ ret = hclge_set_vlan_filter_hw(hdev,
+ htons(ETH_P_8021Q),
+ vport->vport_id,
+ vlan_id,
+ true);
+ if (ret) {
+ dev_err(&hdev->pdev->dev,
+ "restore vport vlan list failed, ret=%d\n",
+ ret);
+ return;
+ }
+ }
list_del(&vlan->node);
kfree(vlan);
--
2.42.0.windows.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net: hns3: Add error handling for VLAN filter hardware configuration
2025-05-17 14:15 [PATCH] net: hns3: Add error handling for VLAN filter hardware configuration Wentao Liang
@ 2025-05-19 15:30 ` Jijie Shao
[not found] ` <682BD774.007007.29338@cstnet.cn>
0 siblings, 1 reply; 4+ messages in thread
From: Jijie Shao @ 2025-05-19 15:30 UTC (permalink / raw)
To: Wentao Liang, shenjian15, salil.mehta, andrew+netdev, davem,
edumazet, kuba, pabeni
Cc: shaojijie, horms, lanhao, wangpeiyang1, rosenp, liuyonglong,
netdev, linux-kernel, stable
on 2025/5/17 22:15, Wentao Liang wrote:
> The hclge_rm_vport_vlan_table() calls hclge_set_vlan_filter_hw() but does
> not check the return value. This could lead to execution with potentially
> invalid data. A proper implementation can be found in
Hi:
Are there any real functional problems?
Would you please tell me your test cases? I'm going to try to reproduce the problem.
Thanks,
Jijie Shao
> hclge_add_vport_all_vlan_table().
>
> Add error handling after calling hclge_set_vlan_filter_hw(). If
> hclge_set_vlan_filter_hw() fails, log an error message via dev_err() and
> return.
>
> Fixes: c6075b193462 ("net: hns3: Record VF vlan tables")
> Cc: stable@vger.kernel.org # v5.1
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> .../hisilicon/hns3/hns3pf/hclge_main.c | 20 +++++++++++++------
> 1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> index db7845009252..5ab4c7f63766 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> @@ -10141,15 +10141,23 @@ static void hclge_rm_vport_vlan_table(struct hclge_vport *vport, u16 vlan_id,
> {
> struct hclge_vport_vlan_cfg *vlan, *tmp;
> struct hclge_dev *hdev = vport->back;
> + int ret;
>
> list_for_each_entry_safe(vlan, tmp, &vport->vlan_list, node) {
> if (vlan->vlan_id == vlan_id) {
> - if (is_write_tbl && vlan->hd_tbl_status)
> - hclge_set_vlan_filter_hw(hdev,
> - htons(ETH_P_8021Q),
> - vport->vport_id,
> - vlan_id,
> - true);
> + if (is_write_tbl && vlan->hd_tbl_status) {
> + ret = hclge_set_vlan_filter_hw(hdev,
> + htons(ETH_P_8021Q),
> + vport->vport_id,
> + vlan_id,
> + true);
> + if (ret) {
> + dev_err(&hdev->pdev->dev,
> + "restore vport vlan list failed, ret=%d\n",
> + ret);
> + return;
> + }
> + }
>
> list_del(&vlan->node);
> kfree(vlan);
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-05-21 2:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-17 14:15 [PATCH] net: hns3: Add error handling for VLAN filter hardware configuration Wentao Liang
2025-05-19 15:30 ` Jijie Shao
[not found] ` <682BD774.007007.29338@cstnet.cn>
2025-05-20 14:37 ` [PATCH] net: hns3: Add error handling for VLAN filter hardwareconfiguration Simon Horman
2025-05-21 2:43 ` Jijie Shao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).