Skip to content

Commit 0247b16

Browse files
shemmingertmonjalo
authored andcommitted
bpf: add allocation annotations to functions
In commit 80da7ef ("eal: annotate allocation functions") helper macros were added to provide compiler information to detect misuse of alloc/free combinations. This covered many of the functions in DPDK but missed the case of data allocated by BPF load functions. Signed-off-by: Stephen Hemminger <[email protected]> Acked-by: Konstantin Ananyev <[email protected]> Reviewed-by: Marat Khalili <[email protected]>
1 parent 367e950 commit 0247b16

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/bpf/rte_bpf.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <rte_common.h>
2020
#include <rte_mbuf.h>
21+
#include <rte_malloc.h>
2122
#include <bpf_def.h>
2223

2324
#ifdef __cplusplus
@@ -128,7 +129,8 @@ rte_bpf_destroy(struct rte_bpf *bpf);
128129
* - ENOMEM - can't reserve enough memory
129130
*/
130131
struct rte_bpf *
131-
rte_bpf_load(const struct rte_bpf_prm *prm);
132+
rte_bpf_load(const struct rte_bpf_prm *prm)
133+
__rte_malloc __rte_dealloc(rte_bpf_destroy, 1);
132134

133135
/**
134136
* Create a new eBPF execution context and load BPF code from given ELF
@@ -152,7 +154,9 @@ rte_bpf_load(const struct rte_bpf_prm *prm);
152154
*/
153155
struct rte_bpf *
154156
rte_bpf_elf_load(const struct rte_bpf_prm *prm, const char *fname,
155-
const char *sname);
157+
const char *sname)
158+
__rte_malloc __rte_dealloc(rte_bpf_destroy, 1);
159+
156160
/**
157161
* Execute given BPF bytecode.
158162
*
@@ -228,7 +232,8 @@ struct bpf_program;
228232
* - ENOTSUP - operation not supported
229233
*/
230234
struct rte_bpf_prm *
231-
rte_bpf_convert(const struct bpf_program *prog);
235+
rte_bpf_convert(const struct bpf_program *prog)
236+
__rte_malloc __rte_dealloc_free;
232237

233238
#ifdef __cplusplus
234239
}

0 commit comments

Comments
 (0)