net/iavf: fix null pointer dereference in eCPRI rule
authorSimei Su <simei.su@intel.com>
Thu, 14 Jan 2021 05:23:24 +0000 (13:23 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 19 Jan 2021 02:30:13 +0000 (03:30 +0100)
A pointer has already been dereferenced before checking if it is NULL.
It doesn't make any sense, so correct to avoid it.

Coverity issue: 365290
Fixes: f57ebdae3cd0 ("net/iavf: support eCPRI message type 0 for RSS")

Signed-off-by: Simei Su <simei.su@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
drivers/net/iavf/iavf_hash.c

index ebaac58..958c73c 100644 (file)
@@ -597,11 +597,12 @@ iavf_hash_parse_pattern(const struct rte_flow_item pattern[], uint64_t *phint,
                        break;
                case RTE_FLOW_ITEM_TYPE_ECPRI:
                        ecpri = item->spec;
-                       ecpri_common.u32 = rte_be_to_cpu_32(
-                                               ecpri->hdr.common.u32);
                        if (!ecpri)
                                break;
-                       else if (ecpri_common.type !=
+
+                       ecpri_common.u32 = rte_be_to_cpu_32(ecpri->hdr.common.u32);
+
+                       if (ecpri_common.type !=
                                 RTE_ECPRI_MSG_TYPE_IQ_DATA) {
                                rte_flow_error_set(error, EINVAL,
                                        RTE_FLOW_ERROR_TYPE_ITEM, item,