diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c index 0e77b2cf61ecc3453ecbf24646b1c0718b125ac5..08b1d5ce9020b0aaff0dda4e0e2b5999376ba6c2 100644 --- a/tools/perf/tests/attr.c +++ b/tools/perf/tests/attr.c @@ -136,7 +136,7 @@ void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu, { int errno_saved = errno; - if (store_event(attr, pid, cpu, fd, group_fd, flags)) { + if ((fd != -1) && store_event(attr, pid, cpu, fd, group_fd, flags)) { pr_err("test attr FAILED"); exit(128); }