DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jasvinder Singh <jasvinder.singh@intel.com>
To: dev@dpdk.org
Cc: jingjing.wu@intel.com, john.mcnamara@intel.com
Subject: [dpdk-dev] [PATCH] app/testpmd: fix dereference null return valiue
Date: Mon, 22 Jan 2018 15:45:53 +0000	[thread overview]
Message-ID: <20180122154553.108360-1-jasvinder.singh@intel.com> (raw)

Calloc() function might returns NULL due to insufficient space. Therefore,
check for handling memory allocation failure is added.

Coverity issue: 257030
Fixes: 5b590fbe09b6 ("app/testpmd: add traffic management forwarding mode")

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
---
 app/test-pmd/tm.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/app/test-pmd/tm.c b/app/test-pmd/tm.c
index b76335c..7231552 100644
--- a/app/test-pmd/tm.c
+++ b/app/test-pmd/tm.c
@@ -575,6 +575,10 @@ softport_tm_tc_node_add(portid_t port_id, struct tm_hierarchy *h,
 				tc_parent_node_id = h->pipe_node_id[i][j];
 				tnp.shared_shaper_id =
 					(uint32_t *)calloc(1, sizeof(uint32_t));
+				if (tnp.shared_shaper_id == NULL) {
+					printf("Shared shaper mem alloc err\n");
+					return -1;
+				}
 				tnp.shared_shaper_id[0] = k;
 				pos = j + (i * PIPE_NODES_PER_SUBPORT);
 				h->tc_node_id[pos][k] =
-- 
2.9.3

             reply	other threads:[~2018-01-22 15:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-22 15:45 Jasvinder Singh [this message]
2018-01-31 22:29 ` Thomas Monjalon
  -- strict thread matches above, loose matches on Subject: below --
2018-01-22 15:15 Jasvinder Singh
2018-01-31 22:27 ` 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=20180122154553.108360-1-jasvinder.singh@intel.com \
    --to=jasvinder.singh@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=john.mcnamara@intel.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).