[PATCH 15/15] samples/bpf: Reset global variables

From: Arnaldo Carvalho de Melo
Date: Mon Feb 13 2017 - 20:14:30 EST


From: MickaÃl SalaÃn <mic@xxxxxxxxxxx>

Before loading a new ELF, clean previous kernel version, license and
processed sections.

Signed-off-by: MickaÃl SalaÃn <mic@xxxxxxxxxxx>
Acked-by: Joe Stringer <joe@xxxxxxx>
Acked-by: Wang Nan <wangnan0@xxxxxxxxxx>
Cc: Alexei Starovoitov <ast@xxxxxx>
Cc: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
Cc: David S. Miller <davem@xxxxxxxxxxxxx>
Cc: netdev@xxxxxxxxxxxxxxx
Link: http://lkml.kernel.org/r/20170208202744.16274-3-mic@xxxxxxxxxxx
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
samples/bpf/bpf_load.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/samples/bpf/bpf_load.c b/samples/bpf/bpf_load.c
index e04fe09d7c2e..b86ee54da2d1 100644
--- a/samples/bpf/bpf_load.c
+++ b/samples/bpf/bpf_load.c
@@ -277,6 +277,11 @@ int load_bpf_file(char *path)
Elf_Data *data, *data_prog, *symbols = NULL;
char *shname, *shname_prog;

+ /* reset global variables */
+ kern_version = 0;
+ memset(license, 0, sizeof(license));
+ memset(processed_sec, 0, sizeof(processed_sec));
+
if (elf_version(EV_CURRENT) == EV_NONE)
return 1;

--
2.9.3