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:15:04 +0000 [thread overview]
Message-ID: <20180122151504.107427-1-jasvinder.singh@intel.com> (raw)
Malloc() function might return NULL due to insufficient space. Therefore,
check for handling memory allocation failure is added.
Coverity issue: 257039
Fixes: e63b50162aa3 ("app/testpmd: clean metering and policing commands")
Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
---
app/test-pmd/cmdline_mtr.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c
index 96a851b..f908fb3 100644
--- a/app/test-pmd/cmdline_mtr.c
+++ b/app/test-pmd/cmdline_mtr.c
@@ -86,6 +86,8 @@ parse_dscp_table_entries(char *str, enum rte_mtr_color *dscp_table)
/* Allocate memory for dscp table */
dscp_table = (enum rte_mtr_color *)malloc(MAX_DSCP_TABLE_ENTRIES *
sizeof(enum rte_mtr_color));
+ if (dscp_table == NULL)
+ return -1;
while (1) {
if (strcmp(token, "G") == 0 ||
@@ -105,8 +107,10 @@ parse_dscp_table_entries(char *str, enum rte_mtr_color *dscp_table)
break;
token = strtok_r(str, PARSE_DELIMITER, &str);
- if (token == NULL)
+ if (token == NULL) {
+ free(dscp_table);
return -1;
+ }
}
return 0;
}
--
2.9.3
next reply other threads:[~2018-01-22 15:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-22 15:15 Jasvinder Singh [this message]
2018-01-31 22:27 ` Thomas Monjalon
2018-01-22 15:45 Jasvinder Singh
2018-01-31 22:29 ` 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=20180122151504.107427-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).