drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c:951 otx2_get_fecparam() warn: always true condition '(pfvf->linfo.fec < 4) => (0-3 < 4)'
From: kernel test robot
Date: Fri Jul 23 2021 - 02:25:37 EST
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 8baef6386baaefb776bdd09b5c7630cf057c51c6
commit: d0cf9503e908ee7b235a5efecedeb74aabc482f3 octeontx2-pf: ethtool fec mode support
date: 5 months ago
config: ia64-randconfig-m031-20210723 (attached as .config)
compiler: ia64-linux-gcc (GCC) 10.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
New smatch warnings:
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c:951 otx2_get_fecparam() warn: always true condition '(pfvf->linfo.fec < 4) => (0-3 < 4)'
Old smatch warnings:
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c:962 otx2_get_fecparam() error: buffer overflow 'fec' 4 <= 4
vim +951 drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
939
940 static int otx2_get_fecparam(struct net_device *netdev,
941 struct ethtool_fecparam *fecparam)
942 {
943 struct otx2_nic *pfvf = netdev_priv(netdev);
944 struct cgx_fw_data *rsp;
945 const int fec[] = {
946 ETHTOOL_FEC_OFF,
947 ETHTOOL_FEC_BASER,
948 ETHTOOL_FEC_RS,
949 ETHTOOL_FEC_BASER | ETHTOOL_FEC_RS};
950 #define FEC_MAX_INDEX 4
> 951 if (pfvf->linfo.fec < FEC_MAX_INDEX)
952 fecparam->active_fec = fec[pfvf->linfo.fec];
953
954 rsp = otx2_get_fwdata(pfvf);
955 if (IS_ERR(rsp))
956 return PTR_ERR(rsp);
957
958 if (rsp->fwdata.supported_fec <= FEC_MAX_INDEX) {
959 if (!rsp->fwdata.supported_fec)
960 fecparam->fec = ETHTOOL_FEC_NONE;
961 else
962 fecparam->fec = fec[rsp->fwdata.supported_fec];
963 }
964 return 0;
965 }
966
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx
Attachment:
.config.gz
Description: application/gzip