From patchwork Fri Nov 9 16:12:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jasvinder Singh X-Patchwork-Id: 47971 X-Patchwork-Delegate: cristian.dumitrescu@intel.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 7BAB34C94; Fri, 9 Nov 2018 17:12:30 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id BBF26493D for ; Fri, 9 Nov 2018 17:12:28 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Nov 2018 08:12:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,483,1534834800"; d="scan'208";a="248436091" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.222.149]) by orsmga004.jf.intel.com with ESMTP; 09 Nov 2018 08:12:26 -0800 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com Date: Fri, 9 Nov 2018 16:12:25 +0000 Message-Id: <20181109161225.91417-1-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] examples/ip_pipeline: fix null pointer deref 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 null pointer dereference issue raised by coverity. Coverity issue: 325728, 325729, 325731, 325738 Fixes: 27b333b23237 ("examples/ip_pipeline: track table rules on add bulk") Signed-off-by: Jasvinder Singh Acked-by: Cristian Dumitrescu Acked-by: Cristian Dumitrescu --- examples/ip_pipeline/cli.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c index 3de620682..910386282 100644 --- a/examples/ip_pipeline/cli.c +++ b/examples/ip_pipeline/cli.c @@ -6841,20 +6841,26 @@ cli_rule_file_process(const char *file_name, return 0; cli_rule_file_process_free: - *rule_list = NULL; - *n_rules = rule_id; - *line_number = line_id; + if (rule_list != NULL) + *rule_list = NULL; - for ( ; ; ) { - struct table_rule *rule; + if (n_rules != NULL) + *n_rules = rule_id; - rule = TAILQ_FIRST(list); - if (rule == NULL) - break; + if (line_number != NULL) + *line_number = line_id; - TAILQ_REMOVE(list, rule, node); - free(rule); - } + if (list != NULL) + for ( ; ; ) { + struct table_rule *rule; + + rule = TAILQ_FIRST(list); + if (rule == NULL) + break; + + TAILQ_REMOVE(list, rule, node); + free(rule); + } if (f) fclose(f);