Skip to content

Commit

Permalink
net/mlx5: fix uninit value use
Browse files Browse the repository at this point in the history
Avoid use of uninitialized state variable.

In case of mlx5e_tx_reporter_build_diagnose_output_sq_common() it's better
to still collect other data than bail out entirely.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/netdev/8bd30131-c9f2-4075-a575-7fa2793a1760@moroto.mountain
Fixes: d17f98b ("net/mlx5: devlink health: use retained error fmsg API")
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Link: https://lore.kernel.org/r/20231025145050.36114-1-przemyslaw.kitszel@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Przemek Kitszel authored and Jakub Kicinski committed Oct 26, 2023
1 parent ec4c20c commit 5af8d8c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,12 @@ mlx5e_rx_reporter_build_diagnose_output_rq_common(struct mlx5e_rq *rq,
if (rq->icosq) {
struct mlx5e_icosq *icosq = rq->icosq;
u8 icosq_hw_state;
int err;

err = mlx5_core_query_sq_state(rq->mdev, icosq->sqn, &icosq_hw_state);
if (err)
return err;

mlx5_core_query_sq_state(rq->mdev, icosq->sqn, &icosq_hw_state);
mlx5e_reporter_icosq_diagnose(icosq, icosq_hw_state, fmsg);
}

Expand Down
8 changes: 6 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,16 @@ mlx5e_tx_reporter_build_diagnose_output_sq_common(struct devlink_fmsg *fmsg,
bool stopped = netif_xmit_stopped(sq->txq);
struct mlx5e_priv *priv = sq->priv;
u8 state;
int err;

mlx5_core_query_sq_state(priv->mdev, sq->sqn, &state);
devlink_fmsg_u32_pair_put(fmsg, "tc", tc);
devlink_fmsg_u32_pair_put(fmsg, "txq ix", sq->txq_ix);
devlink_fmsg_u32_pair_put(fmsg, "sqn", sq->sqn);
devlink_fmsg_u8_pair_put(fmsg, "HW state", state);

err = mlx5_core_query_sq_state(priv->mdev, sq->sqn, &state);
if (!err)
devlink_fmsg_u8_pair_put(fmsg, "HW state", state);

devlink_fmsg_bool_pair_put(fmsg, "stopped", stopped);
devlink_fmsg_u32_pair_put(fmsg, "cc", sq->cc);
devlink_fmsg_u32_pair_put(fmsg, "pc", sq->pc);
Expand Down

0 comments on commit 5af8d8c

Please sign in to comment.