Re: [PATCH v5 1/2] perf stat: Close cork_fd when create_perf_stat_counter() failed

From: Andi Kleen
Date: Wed Sep 25 2024 - 09:56:33 EST


Levi Yun <yeoreum.yun@xxxxxxx> writes:
> +void evlist__cancel_workload(struct evlist *evlist)
> +{
> + int status;
> +
> + if (evlist->workload.cork_fd > 0) {

Technically 0 is a valid file descriptor. Check for >= 0
And make sure the field is initialized with -1

The rest looks fine to me.

Reviewed-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>