summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Moore <paul@paul-moore.com>2017-02-23 15:04:47 -0500
committerPaul Moore <paul@paul-moore.com>2017-02-23 15:04:47 -0500
commite87d1155acab12e1f038d2ddf2d6af3f8cc04ba8 (patch)
treec32f32fefb67df720c64a23801c651403beece79
parentcd509da6cd34caefa79273fe88984188c10e030d (diff)
downloadlibseccomp-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.c16
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;
}
/**