[5/5] net/nfp: fix null pointer dereferences

Message ID 20231115032310.756221-6-chaoyong.he@corigine.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series fix coverity 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/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS

Commit Message

Chaoyong He Nov. 15, 2023, 3:23 a.m. UTC
  CI found null pointer dereferences problem.

Coverity issue: 385406
Fixes: d7f6d9b21ffa ("net/nfp: adjust coding style for NFDk")
Cc: stable@dpdk.org

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 3 +++
 1 file changed, 3 insertions(+)
  

Patch

diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index 1f330b7bb6..0141fbcc8f 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -301,6 +301,9 @@  nfp_net_nfdk_xmit_pkts_common(void *tx_queue,
 		uint64_t metadata = 0;
 
 		pkt = *(tx_pkts + npkts);
+		if (pkt == NULL)
+			goto xmit_end;
+
 		nop_descs = nfp_net_nfdk_tx_maybe_close_block(txq, pkt);
 		if (nop_descs < 0)
 			goto xmit_end;