net/enic: fix dereference before null check

Message ID 20220214204610.14921-1-johndale@cisco.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/enic: fix dereference before null check |

Checks

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

Commit Message

John Daley (johndale) Feb. 14, 2022, 8:46 p.m. UTC
  This patch fixes an issue found by coverity. It checks for a possible
null value of "error" before dereferencing it.

CID: 375064: Dereference after null check
Either the check against null is unnecessary, or there may be a null
pointer dereference.

Coverity issue: 375064
Fixes: ee806eea59fe ("net/enic: support GENEVE flow item")

Signed-off-by: John Daley <johndale@cisco.com>
Reviewed-by: Hyong Youb Kim <hyonkim@cisco.com>
---
 drivers/net/enic/enic_fm_flow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Ferruh Yigit Feb. 15, 2022, 1:01 p.m. UTC | #1
On 2/14/2022 8:46 PM, John Daley wrote:
> This patch fixes an issue found by coverity. It checks for a possible
> null value of "error" before dereferencing it.
> 
> CID: 375064: Dereference after null check
> Either the check against null is unnecessary, or there may be a null
> pointer dereference.
> 
> Coverity issue: 375064
> Fixes: ee806eea59fe ("net/enic: support GENEVE flow item")
> 
> Signed-off-by: John Daley <johndale@cisco.com>
> Reviewed-by: Hyong Youb Kim <hyonkim@cisco.com>

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

Patch

diff --git a/drivers/net/enic/enic_fm_flow.c b/drivers/net/enic/enic_fm_flow.c
index f0bda19a70..c87d3af847 100644
--- a/drivers/net/enic/enic_fm_flow.c
+++ b/drivers/net/enic/enic_fm_flow.c
@@ -1204,7 +1204,7 @@  enic_fm_copy_entry(struct enic_flowman *fm,
 		ret = item_info->copy_item(&args);
 		if (ret) {
 			/* If copy_item set the error, return that */
-			if (error->type != RTE_FLOW_ERROR_TYPE_NONE)
+			if (error && error->type != RTE_FLOW_ERROR_TYPE_NONE)
 				return ret;
 			goto item_not_supported;
 		}