From e87d1155acab12e1f038d2ddf2d6af3f8cc04ba8 Mon Sep 17 00:00:00 2001 From: Paul Moore Date: Thu, 23 Feb 2017 15:04:47 -0500 Subject: bpf: make sure we always clean up all of the BPF temporary state Signed-off-by: Paul Moore --- src/gen_bpf.c | 16 ++++++++-------- 1 file 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; } /** -- cgit v1.2.1