From: Alejandro Lucero Date: Mon, 8 Apr 2019 09:59:49 +0000 (+0100) Subject: net/nfp: check return value X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=0fec453d583c77fd0e7fb61a0284dc261f2b50e3;p=dpdk.git 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 --- diff --git a/drivers/net/nfp/nfpcore/nfp-common/nfp_cppat.h b/drivers/net/nfp/nfpcore/nfp-common/nfp_cppat.h index 6e380cca0e..538f882bf2 100644 --- a/drivers/net/nfp/nfpcore/nfp-common/nfp_cppat.h +++ b/drivers/net/nfp/nfpcore/nfp-common/nfp_cppat.h @@ -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 diff --git a/drivers/net/nfp/nfpcore/nfp_cppcore.c b/drivers/net/nfp/nfpcore/nfp_cppcore.c index 75d3c97488..dec4a8b6d1 100644 --- a/drivers/net/nfp/nfpcore/nfp_cppcore.c +++ b/drivers/net/nfp/nfpcore/nfp_cppcore.c @@ -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; }