bpf: add allocation annotations to functions
PATCH 1/1 bpf: add allocation annotations to functions
In commit 80da7efbb4c4 ("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]>
--- lib/bpf/rte_bpf.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
lib/bpf/rte_bpf.h +8 -3
@@ -18,6 +18,7 @@#include <rte_common.h> #include <rte_mbuf.h> +#include <rte_malloc.h> #include <bpf_def.h> #ifdef __cplusplus
@@ -128,7 +129,8 @@ rte_bpf_destroy(struct rte_bpf *bpf);* - ENOMEM - can't reserve enough memory */ struct rte_bpf * -rte_bpf_load (const struct rte_bpf_prm *prm); +rte_bpf_load (const struct rte_bpf_prm *prm) + __rte_malloc__rte_dealloc (rte_bpf_destroy,1 );/** * 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);*/ struct rte_bpf *rte_bpf_elf_load (const struct rte_bpf_prm *prm,const char *fname, -const char *sname); +const char *sname) + __rte_malloc__rte_dealloc (rte_bpf_destroy,1 ); +/** * Execute given BPF bytecode. *
@@ -228,7 +232,8 @@ struct bpf_program;* - ENOTSUP - operation not supported */ struct rte_bpf_prm * -rte_bpf_convert (const struct bpf_program *prog); +rte_bpf_convert (const struct bpf_program *prog) + __rte_malloc __rte_dealloc_free; #ifdef __cplusplus }
Signature · 1 line
2.47.2