DPDK patches and discussions
 help / color / mirror / Atom feed
From: Marcin Kerlin <marcinx.kerlin@intel.com>
To: olivier.matz@6wind.com
Cc: dev@dpdk.org, Marcin Kerlin <marcinx.kerlin@intel.com>
Subject: [dpdk-dev] [PATCH 1/1] lib/librte_cmdline: fix added checking return value
Date: Mon, 16 May 2016 17:18:08 +0200	[thread overview]
Message-ID: <1463411889-22245-1-git-send-email-marcinx.kerlin@intel.com> (raw)

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 <marcinx.kerlin@intel.com>
---
 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

             reply	other threads:[~2016-05-16 14:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-16 15:18 Marcin Kerlin [this message]
2016-05-17  8:36 ` [dpdk-dev] [PATCH v2] cmdline: check return value at initialization Olivier Matz
2016-05-19 12:26   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1463411889-22245-1-git-send-email-marcinx.kerlin@intel.com \
    --to=marcinx.kerlin@intel.com \
    --cc=dev@dpdk.org \
    --cc=olivier.matz@6wind.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).