diff options
author | Paul Moore <paul@paul-moore.com> | 2017-02-23 15:04:47 -0500 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2017-02-23 15:04:47 -0500 |
commit | e87d1155acab12e1f038d2ddf2d6af3f8cc04ba8 (patch) | |
tree | c32f32fefb67df720c64a23801c651403beece79 | |
parent | cd509da6cd34caefa79273fe88984188c10e030d (diff) | |
download | libseccomp-e87d1155acab12e1f038d2ddf2d6af3f8cc04ba8.tar.gz |
bpf: make sure we always clean up all of the BPF temporary state
Signed-off-by: Paul Moore <paul@paul-moore.com>
-rw-r--r-- | src/gen_bpf.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/gen_bpf.c b/src/gen_bpf.c index 54df2ef..0b6e95a 100644 --- a/src/gen_bpf.c +++ b/src/gen_bpf.c @@ -1945,22 +1945,22 @@ struct bpf_program *gen_bpf_generate(const struct db_filter_col *col) { int rc; struct bpf_state state; + struct bpf_program *prgm; memset(&state, 0, sizeof(state)); state.attr = &col->attr; - state.bpf = zmalloc(sizeof(*(state.bpf))); - if (state.bpf == NULL) + prgm = zmalloc(sizeof(*(prgm))); + if (prgm == NULL) return NULL; + state.bpf = prgm; rc = _gen_bpf_build_bpf(&state, col); - if (rc < 0) - goto bpf_generate_end; + if (rc == 0) + state.bpf = NULL; + _state_release(&state); -bpf_generate_end: - if (rc < 0) - _state_release(&state); - return state.bpf; + return prgm; } /** |