From patchwork Wed Jan 24 15:05:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liang, Ma" X-Patchwork-Id: 34416 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5C52F1B1BE; Wed, 24 Jan 2018 16:05:45 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id EAD811B198 for ; Wed, 24 Jan 2018 16:05:41 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jan 2018 07:05:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,408,1511856000"; d="scan'208";a="12697242" Received: from silpixa00398162.ir.intel.com (HELO silpixa00398162.ger.corp.intel.com) ([10.237.223.171]) by fmsmga007.fm.intel.com with ESMTP; 24 Jan 2018 07:05:40 -0800 From: Liang Ma To: dev@dpdk.org Cc: harry.van.haaren@intel.com, bruce.richardson@intel.com, peter.mccarthy@intel.com, jerin.jacob@caviumnetworks.com Date: Wed, 24 Jan 2018 15:05:51 +0000 Message-Id: <1516806351-151804-2-git-send-email-liang.j.ma@intel.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1516806351-151804-1-git-send-email-liang.j.ma@intel.com> References: <1516806351-151804-1-git-send-email-liang.j.ma@intel.com> Subject: [dpdk-dev] [PATCH 2/2] event/opdl: fix dereference before null check X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Fixes: 4236ce9bf5bf ("event/opdl: add OPDL ring infrastructure library") Coverity issue: 257022 Signed-off-by: Liang Ma --- drivers/event/opdl/opdl_ring.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/event/opdl/opdl_ring.c b/drivers/event/opdl/opdl_ring.c index 7e16d4d..39dc41d 100644 --- a/drivers/event/opdl/opdl_ring.c +++ b/drivers/event/opdl/opdl_ring.c @@ -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; }