Skip to content

Commit bc900a7

Browse files
spandruvadagregkh
authored andcommitted
tools/power/x86/intel-speed-select: Increase string size
[ Upstream commit 2e70b71 ] The current string size to print cpulist can accommodate upto 80 logical CPUs per package. But this limit is not enough. So increase the string size. Also prevent buffer overflow, if the string size reaches limit. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 125b359 commit bc900a7

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎tools/power/x86/intel-speed-select/isst-display.c‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ static void printcpulist(int str_len, char *str, int mask_size,
2525
index = snprintf(&str[curr_index],
2626
str_len - curr_index, ",");
2727
curr_index += index;
28+
if (curr_index >= str_len)
29+
break;
2830
}
2931
index = snprintf(&str[curr_index], str_len - curr_index, "%d",
3032
i);
3133
curr_index += index;
34+
if (curr_index >= str_len)
35+
break;
3236
first = 0;
3337
}
3438
}
@@ -64,10 +68,14 @@ static void printcpumask(int str_len, char *str, int mask_size,
6468
index = snprintf(&str[curr_index], str_len - curr_index, "%08x",
6569
mask[i]);
6670
curr_index += index;
71+
if (curr_index >= str_len)
72+
break;
6773
if (i) {
6874
strncat(&str[curr_index], ",", str_len - curr_index);
6975
curr_index++;
7076
}
77+
if (curr_index >= str_len)
78+
break;
7179
}
7280

7381
free(mask);
@@ -185,7 +193,7 @@ static void _isst_pbf_display_information(int cpu, FILE *outf, int level,
185193
int disp_level)
186194
{
187195
char header[256];
188-
char value[256];
196+
char value[512];
189197

190198
snprintf(header, sizeof(header), "speed-select-base-freq-properties");
191199
format_and_print(outf, disp_level, header, NULL);
@@ -349,7 +357,7 @@ void isst_ctdp_display_information(int cpu, FILE *outf, int tdp_level,
349357
struct isst_pkg_ctdp *pkg_dev)
350358
{
351359
char header[256];
352-
char value[256];
360+
char value[512];
353361
static int level;
354362
int i;
355363

0 commit comments

Comments
 (0)