net/af_xdp: fix integer handling issues

Message ID 20230221111426.172357-1-shibin.koikkara.reeny@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/af_xdp: fix integer handling issues |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build fail github build: failed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-testing fail Testing issues
ci/iol-x86_64-unit-testing fail Testing issues
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Koikkara Reeny, Shibin Feb. 21, 2023, 11:14 a.m. UTC
  Fix integer handling issues (NEGATIVE_RETURNS) reported
in coverity scan. Add a check to sock variable if the
value is negative return -1.

Coverity issue: 383245
Fixes: 7fc6ae50369d ("net/af_xdp: support CNI Integration")

Signed-off-by: Shibin Koikkara Reeny <shibin.koikkara.reeny@intel.com>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Ferruh Yigit Feb. 21, 2023, 1:30 p.m. UTC | #1
On 2/21/2023 11:14 AM, Shibin Koikkara Reeny wrote:
> Fix integer handling issues (NEGATIVE_RETURNS) reported
> in coverity scan. Add a check to sock variable if the
> value is negative return -1.
> 
> Coverity issue: 383245
> Fixes: 7fc6ae50369d ("net/af_xdp: support CNI Integration")
> 
> Signed-off-by: Shibin Koikkara Reeny <shibin.koikkara.reeny@intel.com>

Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>

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

Patch

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 02c874d51e..2a20a6960c 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -1508,6 +1508,8 @@  get_cni_fd(char *if_name)
 
 	memset(&server, 0, sizeof(server));
 	sock = init_uds_sock(&server);
+	if (sock < 0)
+		return -1;
 
 	/* Initiates handshake to CNI send: /connect,hostname */
 	snprintf(request, sizeof(request), "%s,%s", UDS_CONNECT_MSG, hostname);