From: Jie Liu <[email protected]>

sxe2_drv_flow_filter_add() assigns flow->flow_id from the response
even when the firmware command fails, overwriting any previously
set flow id with the zero-initialized response value.

Return early on command failure so flow->flow_id is preserved, and
set flow->create_err on both the success and error paths.

Cc: [email protected]
Cc: [email protected]
Signed-off-by: Jie Liu <[email protected]>
---
 drivers/net/sxe2/sxe2_cmd_chnl.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/sxe2/sxe2_cmd_chnl.c b/drivers/net/sxe2/sxe2_cmd_chnl.c
index 8c45554637..e0c45ae0e3 100644
--- a/drivers/net/sxe2/sxe2_cmd_chnl.c
+++ b/drivers/net/sxe2/sxe2_cmd_chnl.c
@@ -1837,9 +1837,13 @@ int32_t sxe2_drv_flow_filter_add(struct sxe2_adapter 
*adapter, struct sxe2_flow
        sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_FLOW_FILTER_ADD, 
&req,
                           sizeof(req), &resp, sizeof(resp));
        ret = sxe2_drv_cmd_exec(cdev, &cmd);
-       if (ret)
+       if (ret) {
                PMD_DEV_LOG_ERR(adapter, DRV, "Failed to add flow filter, ret: 
%d.", ret);
+               goto l_end;
+       }
        flow->flow_id = resp.flow_id;
+
+l_end:
        flow->create_err = ret;
        return ret;
 }
-- 
2.52.0

Reply via email to