test_bpf: avoid oopsing the kernel when generate_test_data() fails.
authorNicolas Schichan <nschichan@freebox.fr>
Tue, 4 Aug 2015 13:19:07 +0000 (15:19 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 7 Aug 2015 05:02:31 +0000 (22:02 -0700)
Signed-off-by: Nicolas Schichan <nschichan@freebox.fr>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
lib/test_bpf.c

index 3afddf2026c983d279fe822a0c42b7f1a65f193a..6843d0b6203295910bf500691f7301cb1b695e93 100644 (file)
@@ -4672,6 +4672,11 @@ static int run_one(const struct bpf_prog *fp, struct bpf_test *test)
                        break;
 
                data = generate_test_data(test, i);
+               if (!data && !(test->aux & FLAG_NO_DATA)) {
+                       pr_cont("data generation failed ");
+                       err_cnt++;
+                       break;
+               }
                ret = __run_one(fp, data, runs, &duration);
                release_test_data(test, data);