net/nfp: check return value

Call to CPP read (nfp_cpp_readl()) can fail, return 0 on fail.

If the call to _nfp6000_cppat_mu_locality fails, the function needs
to return with an error.

If the nfp_cpp_readl() call fails just returns 0.

Coverity issue: 277209, 277215, 277225
Fixes: c7e9729da6b5 ("net/nfp: support CPP")
Cc: stable@dpdk.org

Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
This commit is contained in:
Alejandro Lucero 2019-04-08 10:59:49 +01:00 committed by Ferruh Yigit
parent 3243f7c0d8
commit 0fec453d58
2 changed files with 9 additions and 3 deletions

View File

@ -368,6 +368,9 @@ _nfp6000_encode_mu(uint64_t *addr, int dest_island, int mode, int addr40,
isld[1] = isld1;
locality_lsb = _nfp6000_cppat_mu_locality_lsb(mode, addr40);
if (locality_lsb < 0)
return NFP_ERRNO(EINVAL);
if (((*addr >> locality_lsb) & 3) == _NIC_NFP6000_MU_LOCALITY_DIRECT)
da = 1;
else

View File

@ -801,7 +801,8 @@ __nfp_cpp_model_autodetect(struct nfp_cpp *cpp)
uint32_t arm_id = NFP_CPP_ID(NFP_CPP_TARGET_ARM, 0, 0);
uint32_t model = 0;
nfp_cpp_readl(cpp, arm_id, NFP6000_ARM_GCSR_SOFTMODEL0, &model);
if (nfp_cpp_readl(cpp, arm_id, NFP6000_ARM_GCSR_SOFTMODEL0, &model))
return 0;
if (NFP_CPP_MODEL_IS_6000(model)) {
uint32_t tmp;
@ -810,8 +811,10 @@ __nfp_cpp_model_autodetect(struct nfp_cpp *cpp)
/* The PL's PluDeviceID revision code is authoratative */
model &= ~0xff;
nfp_xpb_readl(cpp, NFP_XPB_DEVICE(1, 1, 16) +
NFP_PL_DEVICE_ID, &tmp);
if (nfp_xpb_readl(cpp, NFP_XPB_DEVICE(1, 1, 16) +
NFP_PL_DEVICE_ID, &tmp))
return 0;
model |= (NFP_PL_DEVICE_ID_MASK & tmp) - 0x10;
}