From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id A7F589AD3 for ; Mon, 16 May 2016 16:07:47 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 16 May 2016 07:07:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,627,1455004800"; d="scan'208";a="967924493" Received: from gklab-246-021.igk.intel.com (HELO HANLANCREEK9755-232) ([10.217.246.21]) by fmsmga001.fm.intel.com with SMTP; 16 May 2016 07:07:45 -0700 Received: by HANLANCREEK9755-232 (sSMTP sendmail emulation); Mon, 16 May 2016 17:18:17 +0200 From: Marcin Kerlin To: olivier.matz@6wind.com Cc: dev@dpdk.org, Marcin Kerlin Date: Mon, 16 May 2016 17:18:08 +0200 Message-Id: <1463411889-22245-1-git-send-email-marcinx.kerlin@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH 1/1] lib/librte_cmdline: fix added checking return value X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 May 2016 14:07:48 -0000 Unchecked return value: value returned from a function rdline_init is not checked, fix added checking return value and in the case of failure frees memory and return null pointer. Fixes: af75078fece3 ("first public release") Coverity ID 13204 Signed-off-by: Marcin Kerlin --- lib/librte_cmdline/cmdline.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/librte_cmdline/cmdline.c b/lib/librte_cmdline/cmdline.c index c405878..a9c47be 100644 --- a/lib/librte_cmdline/cmdline.c +++ b/lib/librte_cmdline/cmdline.c @@ -130,6 +130,7 @@ struct cmdline * cmdline_new(cmdline_parse_ctx_t *ctx, const char *prompt, int s_in, int s_out) { struct cmdline *cl; + int ret; if (!ctx || !prompt) return NULL; @@ -142,8 +143,13 @@ cmdline_new(cmdline_parse_ctx_t *ctx, const char *prompt, int s_in, int s_out) cl->s_out = s_out; cl->ctx = ctx; - rdline_init(&cl->rdl, cmdline_write_char, - cmdline_valid_buffer, cmdline_complete_buffer); + ret = rdline_init(&cl->rdl, cmdline_write_char, cmdline_valid_buffer, + cmdline_complete_buffer); + if (ret != 0) { + free(cl); + return NULL; + } + cl->rdl.opaque = cl; cmdline_set_prompt(cl, prompt); rdline_newline(&cl->rdl, cl->prompt); -- 1.9.1