bpf: Fix memory leak on object 'data'
[linux-2.6-microblaze.git] / net / bpf / test_run.c
index 6293327..915c2d6 100644 (file)
@@ -161,8 +161,10 @@ static void *bpf_test_init(const union bpf_attr *kattr, u32 size,
            bpf_fentry_test3(4, 5, 6) != 15 ||
            bpf_fentry_test4((void *)7, 8, 9, 10) != 34 ||
            bpf_fentry_test5(11, (void *)12, 13, 14, 15) != 65 ||
-           bpf_fentry_test6(16, (void *)17, 18, 19, (void *)20, 21) != 111)
+           bpf_fentry_test6(16, (void *)17, 18, 19, (void *)20, 21) != 111) {
+               kfree(data);
                return ERR_PTR(-EFAULT);
+       }
        return data;
 }