diff options
| author | Leo Yan <[email protected]> | 2019-07-02 10:25:31 +0000 |
|---|---|---|
| committer | Daniel Borkmann <[email protected]> | 2019-07-03 10:17:29 +0000 |
| commit | 33bae185f74d49a0d7b1bfaafb8e959efce0f243 (patch) | |
| tree | 267fab5843b79dcbc9dde80e5038f9b55334b8a2 /tools/lib/bpf/str_error.c | |
| parent | libbpf: fix GCC8 warning for strncpy (diff) | |
| download | kernel-33bae185f74d49a0d7b1bfaafb8e959efce0f243.tar.gz kernel-33bae185f74d49a0d7b1bfaafb8e959efce0f243.zip | |
bpf, libbpf, smatch: Fix potential NULL pointer dereference
Based on the following report from Smatch, fix the potential NULL
pointer dereference check:
tools/lib/bpf/libbpf.c:3493
bpf_prog_load_xattr() warn: variable dereferenced before check 'attr'
(see line 3483)
3479 int bpf_prog_load_xattr(const struct bpf_prog_load_attr *attr,
3480 struct bpf_object **pobj, int *prog_fd)
3481 {
3482 struct bpf_object_open_attr open_attr = {
3483 .file = attr->file,
3484 .prog_type = attr->prog_type,
^^^^^^
3485 };
At the head of function, it directly access 'attr' without checking
if it's NULL pointer. This patch moves the values assignment after
validating 'attr' and 'attr->file'.
Signed-off-by: Leo Yan <[email protected]>
Acked-by: Yonghong Song <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Diffstat (limited to 'tools/lib/bpf/str_error.c')
0 files changed, 0 insertions, 0 deletions
