Skip to content

Commit 3668ba8

Browse files
lkayal-01gregkh
authored andcommitted
net/mlx5: HWS, Fix uninitialized variables in mlx5hws_pat_calc_nop error flow
[ Upstream commit 24b6e53 ] In mlx5hws_pat_calc_nop(), src_field and dst_field are passed to hws_action_modify_get_target_fields() which should set their values. However, if an invalid action type is encountered, these variables remain uninitialized and are later used to update prev_src_field and prev_dst_field. Initialize both variables to INVALID_FIELD to ensure they have defined values in all code paths. Fixes: 01e035f ("net/mlx5: HWS, handle modify header actions dependency") Signed-off-by: Lama Kayal <lkayal@nvidia.com> Reviewed-by: Tariq Toukan <tariqt@nvidia.com> Signed-off-by: Mark Bloch <mbloch@nvidia.com> Link: https://patch.msgid.link/20250825143435.598584-4-mbloch@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 051fd85 commit 3668ba8

File tree

1 file changed

+3
-1
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/steering/hws

1 file changed

+3
-1
lines changed

drivers/net/ethernet/mellanox/mlx5/core/steering/hws/pat_arg.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,6 @@ int mlx5hws_pat_calc_nop(__be64 *pattern, size_t num_actions,
527527
u32 *nop_locations, __be64 *new_pat)
528528
{
529529
u16 prev_src_field = INVALID_FIELD, prev_dst_field = INVALID_FIELD;
530-
u16 src_field, dst_field;
531530
u8 action_type;
532531
bool dependent;
533532
size_t i, j;
@@ -539,6 +538,9 @@ int mlx5hws_pat_calc_nop(__be64 *pattern, size_t num_actions,
539538
return 0;
540539

541540
for (i = 0, j = 0; i < num_actions; i++, j++) {
541+
u16 src_field = INVALID_FIELD;
542+
u16 dst_field = INVALID_FIELD;
543+
542544
if (j >= max_actions)
543545
return -EINVAL;
544546

0 commit comments

Comments
 (0)