From: Yong Wang <wang.yong19@zte.com.cn>
To: thomas@monjalon.net
Cc: dev@dpdk.org, Yong Wang <wang.yong19@zte.com.cn>
Subject: [dpdk-dev] [PATCH] buildtools: add null point check for calloc
Date: Fri, 15 Sep 2017 07:33:08 -0400 [thread overview]
Message-ID: <1505475188-10681-1-git-send-email-wang.yong19@zte.com.cn> (raw)
In func locate_pmd_entries(), pointer 'new' returned from call to func
'calloc' may be NULL. It is dereferenced without null point check.
Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
---
buildtools/pmdinfogen/pmdinfogen.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/buildtools/pmdinfogen/pmdinfogen.c b/buildtools/pmdinfogen/pmdinfogen.c
index e73fc76..96ccbf3 100644
--- a/buildtools/pmdinfogen/pmdinfogen.c
+++ b/buildtools/pmdinfogen/pmdinfogen.c
@@ -327,6 +327,10 @@ static int locate_pmd_entries(struct elf_info *info)
do {
new = calloc(sizeof(struct pmd_driver), 1);
+ if (new == NULL) {
+ fprintf(stderr, "Failed to calloc memory\n");
+ return -1;
+ }
new->name_sym = find_sym_in_symtab(info, "this_pmd_name", last);
last = new->name_sym;
if (!new->name_sym)
@@ -408,7 +412,8 @@ int main(int argc, char **argv)
}
parse_elf(&info, argv[1]);
- locate_pmd_entries(&info);
+ if (locate_pmd_entries(&info) < 0)
+ exit(1);
if (info.drivers) {
output_pmd_info_string(&info, argv[2]);
--
1.8.3.1
next reply other threads:[~2017-09-15 11:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-15 11:33 Yong Wang [this message]
2017-11-07 22: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=1505475188-10681-1-git-send-email-wang.yong19@zte.com.cn \
--to=wang.yong19@zte.com.cn \
--cc=dev@dpdk.org \
--cc=thomas@monjalon.net \
/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).