event/opdl: fix dereference before null check
authorLiang Ma <liang.j.ma@intel.com>
Wed, 24 Jan 2018 15:05:51 +0000 (15:05 +0000)
committerJerin Jacob <jerin.jacob@caviumnetworks.com>
Wed, 31 Jan 2018 09:42:18 +0000 (10:42 +0100)
Coverity issue: 257022
Fixes: 4236ce9bf5bf ("event/opdl: add OPDL ring infrastructure library")

Signed-off-by: Liang Ma <liang.j.ma@intel.com>
drivers/event/opdl/opdl_ring.c

index 7e16d4d..39dc41d 100644 (file)
@@ -550,6 +550,10 @@ opdl_stage_claim_multithread(struct opdl_stage *s, void *entries,
        uint32_t i = 0, offset;
        uint8_t *entries_offset = (uint8_t *)entries;
 
+       if (seq == NULL) {
+               PMD_DRV_LOG(ERR, "Invalid seq PTR");
+               return 0;
+       }
        offset = opdl_first_entry_id(*seq, s->nb_instance, s->instance_id);
        num_entries = offset + (s->nb_instance * num_entries);
 
@@ -561,8 +565,8 @@ opdl_stage_claim_multithread(struct opdl_stage *s, void *entries,
                entries_offset += t->slot_size;
                i++;
        }
-       if (seq != NULL)
-               *seq = old_head;
+
+       *seq = old_head;
 
        return i;
 }