drivers/net/ethernet/mellanox/mlx5/core/en/port.c:453 mlx5e_fec_in_caps() warn: signedness bug returning '(-95)'

From: Dan Carpenter
Date: Fri Sep 11 2020 - 13:52:14 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 581cb3a26baf846ee9636214afaa5333919875b1
commit: 2132b71f78d207b63974fc7d6eced9c5e886c405 net/mlx5e: Advertise globaly supported FEC modes
config: powerpc-randconfig-m031-20200911 (attached as .config)
compiler: powerpc64-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

New smatch warnings:
drivers/net/ethernet/mellanox/mlx5/core/en/port.c:453 mlx5e_fec_in_caps() warn: signedness bug returning '(-95)'

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2132b71f78d207b63974fc7d6eced9c5e886c405
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 2132b71f78d207b63974fc7d6eced9c5e886c405
vim +453 drivers/net/ethernet/mellanox/mlx5/core/en/port.c

2132b71f78d207 Aya Levin 2020-02-11 444 bool mlx5e_fec_in_caps(struct mlx5_core_dev *dev, int fec_policy)
^^^^

2095b264147753 Shay Agroskin 2018-10-10 445 {
2095b264147753 Shay Agroskin 2018-10-10 446 u32 out[MLX5_ST_SZ_DW(pplm_reg)] = {};
2095b264147753 Shay Agroskin 2018-10-10 447 u32 in[MLX5_ST_SZ_DW(pplm_reg)] = {};
2095b264147753 Shay Agroskin 2018-10-10 448 int sz = MLX5_ST_SZ_BYTES(pplm_reg);
2095b264147753 Shay Agroskin 2018-10-10 449 int err;
2132b71f78d207 Aya Levin 2020-02-11 450 int i;
2095b264147753 Shay Agroskin 2018-10-10 451
2095b264147753 Shay Agroskin 2018-10-10 452 if (!MLX5_CAP_GEN(dev, pcam_reg))
2095b264147753 Shay Agroskin 2018-10-10 @453 return -EOPNOTSUPP;
^^^^^^^^^^^^^^^^^^

2095b264147753 Shay Agroskin 2018-10-10 454
2095b264147753 Shay Agroskin 2018-10-10 455 if (!MLX5_CAP_PCAM_REG(dev, pplm))
2095b264147753 Shay Agroskin 2018-10-10 456 return -EOPNOTSUPP;
^^^^^^^^^^^^^^^^^^
These become "return true;"

2095b264147753 Shay Agroskin 2018-10-10 457
2095b264147753 Shay Agroskin 2018-10-10 458 MLX5_SET(pplm_reg, in, local_port, 1);
2095b264147753 Shay Agroskin 2018-10-10 459 err = mlx5_core_access_reg(dev, in, sz, out, sz, MLX5_REG_PPLM, 0, 0);
2095b264147753 Shay Agroskin 2018-10-10 460 if (err)
2132b71f78d207 Aya Levin 2020-02-11 461 return false;
2095b264147753 Shay Agroskin 2018-10-10 462
2132b71f78d207 Aya Levin 2020-02-11 463 for (i = 0; i < MLX5E_FEC_SUPPORTED_SPEEDS; i++) {
2132b71f78d207 Aya Levin 2020-02-11 464 u8 fec_caps;
2095b264147753 Shay Agroskin 2018-10-10 465
2132b71f78d207 Aya Levin 2020-02-11 466 mlx5e_get_fec_cap_field(out, &fec_caps, fec_supported_speeds[i]);
2132b71f78d207 Aya Levin 2020-02-11 467 if (fec_caps & fec_policy)
2132b71f78d207 Aya Levin 2020-02-11 468 return true;
2132b71f78d207 Aya Levin 2020-02-11 469 }
2132b71f78d207 Aya Levin 2020-02-11 470 return false;
2095b264147753 Shay Agroskin 2018-10-10 471 }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip