Skip to contentSkip to conversation

perf s390: Fix reading cpuid model information

PATCH In review Thomas Richter 3 participants 3 messages Feb 19, 2018 – Feb 21, 2018 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf s390: Fix reading cpuid model information

Commit feb3d2d955c8 (perf record: Provide detailed information on s390 CPU") fixed a build error on Ubuntu. However the fix uses the wrong size to print the model information.

---
 tools/perf/arch/s390/util/header.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/arch/s390/util/header.c +1 -1
index 231294b80dc4..a4c30f1c70be 100644
@@ -81,7 +81,7 @@ int get_cpuid(char *buffer, size_t sz)
 			line2 = line + strlen(SYSINFO_MODEL);
 
 			while ((cp = strtok_r(line2, "\n ", &line2))) {
-				mdsize += scnprintf(model + mdsize, sizeof(type) - mdsize,
+				mdsize += scnprintf(model + mdsize, sizeof(model) - mdsize,
 						    "%s%s", model[0] ? "," : "", cp);
 			}
 			break;
Signature · 1 line
2.14.3
#1 lore raw

Em Mon, Feb 19, 2018 at 11:24:44AM +0100, Thomas Richter escreveu:

Quoted 3 lines

Commit feb3d2d955c8 (perf record: Provide detailed information on s390 CPU") fixed a build error on Ubuntu. However the fix uses the wrong size to print the model information.

Thanks for the review and quick fix, I'm sorry for letting that slip :-\

sizeof(type) is smaller tha sizeof(model), so at least this would just limit the formatted model variable to be at most sizeof(type) in lenght.

Anyway, applying the fix :-)

- Arnaldo

Quoted 20 lines
---
 tools/perf/arch/s390/util/header.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/arch/s390/util/header.c +1 -1
index 231294b80dc4..a4c30f1c70be 100644
@@ -81,7 +81,7 @@ int get_cpuid(char *buffer, size_t sz)
 			line2 = line + strlen(SYSINFO_MODEL);
 
 			while ((cp = strtok_r(line2, "\n ", &line2))) {
-				mdsize += scnprintf(model + mdsize, sizeof(type) - mdsize,
+				mdsize += scnprintf(model + mdsize, sizeof(model) - mdsize,
 						    "%s%s", model[0] ? "," : "", cp);
 			}
 			break;
Signature · 1 line
2.14.3
#2 lore raw
In reply to Thomas Richter
perf s390: Fix reading cpuid model information
Commit-ID:  47812e00910407a0f14906c0a3bf2d803a616c6f
Gitweb:     https://git.kernel.org/tip/47812e00910407a0f14906c0a3bf2d803a616c6f
Author:     Thomas Richter <[email protected]>
AuthorDate: Mon, 19 Feb 2018 11:24:44 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 19 Feb 2018 09:16:01 -0300

perf s390: Fix reading cpuid model information

Commit eca0fa28cd0d (perf record: Provide detailed information on s390 CPU") fixed a build error on Ubuntu. However the fix uses the wrong size to print the model information.

Cc Heiko Carstens <[email protected]>
Cc Hendrik Brueckner <[email protected]>
Cc Martin Schwidefsky <[email protected]>
Fixes eca0fa28cd0d ("perf record: Provide detailed information on s390 CPU")
---
 tools/perf/arch/s390/util/header.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/arch/s390/util/header.c +1 -1
index 231294b..a4c30f1 100644
@@ -81,7 +81,7 @@ int get_cpuid(char *buffer, size_t sz)
 			line2 = line + strlen(SYSINFO_MODEL);
 
 			while ((cp = strtok_r(line2, "\n ", &line2))) {
-				mdsize += scnprintf(model + mdsize, sizeof(type) - mdsize,
+				mdsize += scnprintf(model + mdsize, sizeof(model) - mdsize,
 						    "%s%s", model[0] ? "," : "", cp);
 			}
 			break;