]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Use IS_ERR_OR_NULL() in hashmap__free()
authorMauricio Vásquez <mauricio@kinvolk.io>
Fri, 7 Jan 2022 15:26:19 +0000 (10:26 -0500)
committerAndrii Nakryiko <andrii@kernel.org>
Thu, 13 Jan 2022 01:01:36 +0000 (17:01 -0800)
commitd5d9420eff7536ddddb2203170594e2c5ad7bc68
tree02b727a151b345636d95b4c39a83947cd9d123db
parent2ad9037325ab53d966e9d0af7552d23fd1252670
libbpf: Use IS_ERR_OR_NULL() in hashmap__free()

hashmap__new() uses ERR_PTR() to return an error so it's better to
use IS_ERR_OR_NULL() in order to check the pointer before calling
free(). This will prevent freeing an invalid pointer if somebody calls
hashmap__free() with the result of a failed hashmap__new() call.

Signed-off-by: Mauricio Vásquez <mauricio@kinvolk.io>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20220107152620.192327-1-mauricio@kinvolk.io
tools/lib/bpf/hashmap.c