Skip to content

Commit 00b2842

Browse files
committed
libperf cpumap: Be tolerant of newline at the end of a cpumask
JIRA: https://issues.redhat.com/browse/RHEL-73893 upstream ======== commit 5d2fd51 Author: Ian Rogers <irogers@google.com> Date: Thu Dec 5 20:40:31 2024 -0800 description =========== 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> Signed-off-by: Michael Petlan <mpetlan@redhat.com>
1 parent 8b1ae32 commit 00b2842

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
@@ -240,15 +240,15 @@ struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list)
240240
p = NULL;
241241
start_cpu = strtoul(cpu_list, &p, 0);
242242
if (start_cpu >= INT_MAX
243-
|| (*p != '\0' && *p != ',' && *p != '-'))
243+
|| (*p != '\0' && *p != ',' && *p != '-' && *p != '\n'))
244244
goto invalid;
245245

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

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

254254
if (end_cpu < start_cpu)

0 commit comments

Comments
 (0)