]> git.baikalelectronics.ru Git - kernel.git/commit
net/mlx5e: Fix division by 0 in mlx5e_select_queue
authorMaxim Mikityanskiy <maximmi@mellanox.com>
Mon, 1 Mar 2021 18:59:59 +0000 (20:59 +0200)
committerSaeed Mahameed <saeedm@nvidia.com>
Mon, 22 Mar 2021 20:16:41 +0000 (13:16 -0700)
commitc912b0fa9788f442d1566a02c6257ca32157b964
treefe64c3d0889cee715ca949cfd188bfd6671a2478
parent355c6a9659d1eb3c16e89e1ac460c96ec9d9f89a
net/mlx5e: Fix division by 0 in mlx5e_select_queue

mlx5e_select_queue compares num_tc_x_num_ch to real_num_tx_queues to
determine if HTB and/or PTP offloads are active. If they are, it
calculates netdev_pick_tx() % num_tc_x_num_ch to prevent it from
selecting HTB and PTP queues for regular traffic. However, before the
channels are first activated, num_tc_x_num_ch is zero. If
ndo_select_queue gets called at this point, the HTB/PTP check will pass,
and mlx5e_select_queue will attempt to take a modulo by num_tc_x_num_ch,
which equals to zero.

This commit fixes the bug by assigning num_tc_x_num_ch to a non-zero
value before registering the netdev.

Fixes: 63f9d5b33580 ("net/mlx5e: Support HTB offload")
Reported-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/en_main.c