arch/x86/events/intel/uncore.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Replace sprintf() with sysfs_emit() in uncore_event_show(). sysfs_emit()
is preferred for formatting sysfs output because it provides safer
bounds checking.
Add a terminating newline as suggested by checkpatch.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
Changes in v2:
- Add a terminating newline as suggested by checkpatch
- Link to v1: https://lore.kernel.org/lkml/20260206194254.36105-2-thorsten.blum@linux.dev/
---
arch/x86/events/intel/uncore.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c
index 4684649109d9..86bc1c03b64a 100644
--- a/arch/x86/events/intel/uncore.c
+++ b/arch/x86/events/intel/uncore.c
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
#include <linux/module.h>
+#include <linux/sysfs.h>
#include <asm/cpu_device_id.h>
#include <asm/intel-family.h>
@@ -133,7 +134,7 @@ ssize_t uncore_event_show(struct device *dev,
{
struct uncore_event_desc *event =
container_of(attr, struct uncore_event_desc, attr);
- return sprintf(buf, "%s", event->config);
+ return sysfs_emit(buf, "%s\n", event->config);
}
struct intel_uncore_box *uncore_pmu_to_box(struct intel_uncore_pmu *pmu, int cpu)
On Tue, Apr 21, 2026 at 05:04:50PM +0200, Thorsten Blum wrote:
> Replace sprintf() with sysfs_emit() in uncore_event_show(). sysfs_emit()
> is preferred for formatting sysfs output because it provides safer
> bounds checking.
>
> Add a terminating newline as suggested by checkpatch.
I'm ok with adding it but it may cause a compatibility problem..
But I think perf tools can handle it as other PMUs already emit a
newline at the end.
Acked-by: Namhyung Kim <namhyung@kernel.org>
Thanks,
Namhyung
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> Changes in v2:
> - Add a terminating newline as suggested by checkpatch
> - Link to v1: https://lore.kernel.org/lkml/20260206194254.36105-2-thorsten.blum@linux.dev/
> ---
> arch/x86/events/intel/uncore.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c
> index 4684649109d9..86bc1c03b64a 100644
> --- a/arch/x86/events/intel/uncore.c
> +++ b/arch/x86/events/intel/uncore.c
> @@ -1,5 +1,6 @@
> // SPDX-License-Identifier: GPL-2.0-only
> #include <linux/module.h>
> +#include <linux/sysfs.h>
>
> #include <asm/cpu_device_id.h>
> #include <asm/intel-family.h>
> @@ -133,7 +134,7 @@ ssize_t uncore_event_show(struct device *dev,
> {
> struct uncore_event_desc *event =
> container_of(attr, struct uncore_event_desc, attr);
> - return sprintf(buf, "%s", event->config);
> + return sysfs_emit(buf, "%s\n", event->config);
> }
>
> struct intel_uncore_box *uncore_pmu_to_box(struct intel_uncore_pmu *pmu, int cpu)
© 2016 - 2026 Red Hat, Inc.