Skip to content

Commit 41c5d10

Browse files
ColinIanKingkuba-moo
authored andcommitted
net/mlx5: fix unintentional sign extension on shift of dest_attr->vport.vhca_id
Shifting dest_attr->vport.vhca_id << 16 results in a promotion from an unsigned 16 bit integer to a 32 bit signed integer, this is then sign extended to a 64 bit unsigned long on 64 bitarchitectures. If vhca_id is greater than 0x7fff then this leads to a sign extended result where all the upper 32 bits of idx are set to 1. Fix this by casting vhca_id to the same type as idx before performing the shift. Fixes: 8e2e08a ("net/mlx5: fs, add support for dest vport HWS action") Signed-off-by: Colin Ian King <[email protected]> Reviewed-by: Simon Horman <[email protected]> Acked-by: Moshe Shemesh <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f16312b commit 41c5d10

File tree

1 file changed

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

1 file changed

+1
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ mlx5_fs_get_dest_action_vport(struct mlx5_fs_hws_context *fs_ctx,
417417
vport_num = is_dest_type_uplink ? MLX5_VPORT_UPLINK : dest_attr->vport.num;
418418
if (vhca_id_valid) {
419419
dests_xa = &fs_ctx->hws_pool.vport_vhca_dests;
420-
idx = dest_attr->vport.vhca_id << 16 | vport_num;
420+
idx = (unsigned long)dest_attr->vport.vhca_id << 16 | vport_num;
421421
} else {
422422
dests_xa = &fs_ctx->hws_pool.vport_dests;
423423
idx = vport_num;

0 commit comments

Comments
 (0)