tools lib bpf: Check return value of strdup when reading map names
authorWang Nan <wangnan0@huawei.com>
Tue, 8 Dec 2015 02:25:29 +0000 (02:25 +0000)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 11 Dec 2015 11:51:09 +0000 (08:51 -0300)
commit973170e66726672518eb935eb0dc0e63876d133d
tree08c9cbfc910c13eb1bce3130c0d775e20913f46c
parentbeefb8d0e556aaf3cb69168c5953e023ace6aa78
tools lib bpf: Check return value of strdup when reading map names

Commit 561bbccac72d08babafaa33fd7fa9100ec4c9fb6 ("tools lib bpf:
Extract and collect map names from BPF object file") forgets checking
return value of strdup(). This patch fixes it. It also checks names
pointer before strcmp() for safety.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Fixes: 561bbccac72d ("tools lib bpf: Extract and collect map names from BPF object file")
Link: http://lkml.kernel.org/r/1449541544-67621-2-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/lib/bpf/libbpf.c