summaryrefslogtreecommitdiffstats
path: root/drivers/perf/thunderx2_pmu.c
diff options
context:
space:
mode:
authorQi Liu <liuqi115@huawei.com>2021-03-19 11:04:33 +0100
committerWill Deacon <will@kernel.org>2021-03-25 13:55:44 +0100
commitfb62d67586afc046f3783d819985c737f6b0b666 (patch)
tree812c6b649bc448360dbdf0c19c40e87f27e7962f /drivers/perf/thunderx2_pmu.c
parentdrivers/perf: convert sysfs scnprintf family to sysfs_emit_at() and sysfs_emit() (diff)
downloadlinux-fb62d67586afc046f3783d819985c737f6b0b666.tar.xz
linux-fb62d67586afc046f3783d819985c737f6b0b666.zip
drivers/perf: convert sysfs sprintf family to sysfs_emit
sprintf does not know the PAGE_SIZE maximum of the temporary buffer used for sysfs content and it's possible to overrun the buffer length. Use sysfs_emit() function to ensures that no overrun is done. Signed-off-by: Qi Liu <liuqi115@huawei.com> Link: https://lore.kernel.org/r/1616148273-16374-4-git-send-email-liuqi115@huawei.com Signed-off-by: Will Deacon <will@kernel.org>
Diffstat (limited to 'drivers/perf/thunderx2_pmu.c')
-rw-r--r--drivers/perf/thunderx2_pmu.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/perf/thunderx2_pmu.c b/drivers/perf/thunderx2_pmu.c
index e116815fa809..06a6d569b0b5 100644
--- a/drivers/perf/thunderx2_pmu.c
+++ b/drivers/perf/thunderx2_pmu.c
@@ -128,7 +128,7 @@ __tx2_pmu_##_var##_show(struct device *dev, \
char *page) \
{ \
BUILD_BUG_ON(sizeof(_format) >= PAGE_SIZE); \
- return sprintf(page, _format "\n"); \
+ return sysfs_emit(page, _format "\n"); \
} \
\
static struct device_attribute format_attr_##_var = \
@@ -176,7 +176,7 @@ static ssize_t tx2_pmu_event_show(struct device *dev,
struct dev_ext_attribute *eattr;
eattr = container_of(attr, struct dev_ext_attribute, attr);
- return sprintf(buf, "event=0x%lx\n", (unsigned long) eattr->var);
+ return sysfs_emit(buf, "event=0x%lx\n", (unsigned long) eattr->var);
}
#define TX2_EVENT_ATTR(name, config) \