Skip to content

Commit 5d2fd51

Browse files
captain5050acmel
authored andcommitted
libperf cpumap: Be tolerant of newline at the end of a cpumask
File cpumasks often have a newline that shouldn't trigger the invalid parsing case in perf_cpu_map__new(). Reviewed-by: Leo Yan <leo.yan@arm.com> Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ben Gainey <ben.gainey@arm.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@linaro.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Kyle Meyer <kyle.meyer@hpe.com> 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/20241206044035.1062032-5-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent e8399d3 commit 5d2fd51

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/lib/perf/cpumap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,15 @@ struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list)
241241
p = NULL;
242242
start_cpu = strtoul(cpu_list, &p, 0);
243243
if (start_cpu >= INT_MAX
244-
|| (*p != '\0' && *p != ',' && *p != '-'))
244+
|| (*p != '\0' && *p != ',' && *p != '-' && *p != '\n'))
245245
goto invalid;
246246

247247
if (*p == '-') {
248248
cpu_list = ++p;
249249
p = NULL;
250250
end_cpu = strtoul(cpu_list, &p, 0);
251251

252-
if (end_cpu >= INT_MAX || (*p != '\0' && *p != ','))
252+
if (end_cpu >= INT_MAX || (*p != '\0' && *p != ',' && *p != '\n'))
253253
goto invalid;
254254

255255
if (end_cpu < start_cpu)

0 commit comments

Comments
 (0)