Commit a5740e95 authored by Tian Tao's avatar Tian Tao Committed by Will Deacon

arm64: perf: Convert snprintf to sysfs_emit

Use sysfs_emit instead of snprintf to avoid buf overrun,because in
sysfs_emit it strictly checks whether buf is null or buf whether
pagesize aligned, otherwise it returns an error.
Signed-off-by: default avatarTian Tao <tiantao6@hisilicon.com>
Link: https://lore.kernel.org/r/1621497585-30887-1-git-send-email-tiantao6@hisilicon.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
parent fdbef8c4
...@@ -312,7 +312,7 @@ static ssize_t slots_show(struct device *dev, struct device_attribute *attr, ...@@ -312,7 +312,7 @@ static ssize_t slots_show(struct device *dev, struct device_attribute *attr,
struct arm_pmu *cpu_pmu = container_of(pmu, struct arm_pmu, pmu); struct arm_pmu *cpu_pmu = container_of(pmu, struct arm_pmu, pmu);
u32 slots = cpu_pmu->reg_pmmir & ARMV8_PMU_SLOTS_MASK; u32 slots = cpu_pmu->reg_pmmir & ARMV8_PMU_SLOTS_MASK;
return snprintf(page, PAGE_SIZE, "0x%08x\n", slots); return sysfs_emit(page, "0x%08x\n", slots);
} }
static DEVICE_ATTR_RO(slots); static DEVICE_ATTR_RO(slots);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment