perf daemon: Fix file leak in daemon_session__control
authorSamasth Norway Ananda <samasth.norway.ananda@oracle.com>
Fri, 10 May 2024 00:34:24 +0000 (17:34 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 10 May 2024 14:28:11 +0000 (11:28 -0300)
commit09541603462c399c7408d50295db99b4b8042eaa
treef687f6ec3791e71bd553c2d132e7cdf106484a8f
parent230a7a71f92212e723fa435d4ca5922de33ec88a
perf daemon: Fix file leak in daemon_session__control

The open() function returns -1 on error.

The 'control' and 'ack' file descriptors are both initialized with
open() and further validated with 'if' statement.

'if (!control)' would evaluate to 'true' if returned value on error were
'0' but it is actually '-1'.

Fixes: edcaa47958c7438b ("perf daemon: Add 'ping' command")
Signed-off-by: Samasth Norway Ananda <samasth.norway.ananda@oracle.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240510003424.2016914-1-samasth.norway.ananda@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-daemon.c