summaryrefslogtreecommitdiff
path: root/buildtools
diff options
context:
space:
mode:
authorYong Wang <wang.yong19@zte.com.cn>2017-09-15 07:33:08 -0400
committerThomas Monjalon <thomas@monjalon.net>2017-11-07 23:24:43 +0100
commit3b29f60f2d584d5086b735e0a6fab518a17eaa1e (patch)
tree1de180120d739997cd5ba5471abd5f2e0ae85d57 /buildtools
parentf0df35313faa1d69739f533e41f73782489ded05 (diff)
downloaddpdk-3b29f60f2d584d5086b735e0a6fab518a17eaa1e.zip
dpdk-3b29f60f2d584d5086b735e0a6fab518a17eaa1e.tar.gz
dpdk-3b29f60f2d584d5086b735e0a6fab518a17eaa1e.tar.xz
buildtools: check allocation error in pmdinfogen
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>
Diffstat (limited to 'buildtools')
-rw-r--r--buildtools/pmdinfogen/pmdinfogen.c7
1 files changed, 6 insertions, 1 deletions
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]);