net/nfp: check value returned

Message ID 20190408101008.7706-1-alejandro.lucero@netronome.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/nfp: check value returned |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

Alejandro Lucero April 8, 2019, 10:10 a.m. UTC
  If the call to _nfp6000_cppat_mu_locality fails, the function needs
to return with an error.

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

Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
---
 drivers/net/nfp/nfpcore/nfp-common/nfp_cppat.h | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Ferruh Yigit April 8, 2019, 4:31 p.m. UTC | #1
On 4/8/2019 11:10 AM, Alejandro Lucero wrote:
> If the call to _nfp6000_cppat_mu_locality fails, the function needs
> to return with an error.
> 
> Coverity issue: 277215
> Fixes: c7e9729da6b5 ("net/nfp: support CPP")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>

Applied to dpdk-next-net/master, thanks.

(squashed with other return value check patches, since all are fixing same
commit there wouldn't be any backport concern)
  

Patch

diff --git a/drivers/net/nfp/nfpcore/nfp-common/nfp_cppat.h b/drivers/net/nfp/nfpcore/nfp-common/nfp_cppat.h
index 6e380cca0..538f882bf 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