Commit 03124140 authored by Kai Ye's avatar Kai Ye Committed by JiangShui
Browse files

uacce: use sysfs_emit instead of sprintf

mainline inclusion
from mainline-v5.17-rc1
commit 2d2802fb
category: cleanup
bugzilla: https://gitee.com/openeuler/kernel/issues/T878TZ
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2d2802fb24de8cbacb4a2d6da2e002acc1c17143



----------------------------------------------------------------------

Use the sysfs_emit to replace sprintf. sprintf may cause
output defect in sysfs content, it is better to use new
added sysfs_emit function which knows the size of the
temporary buffer.

Signed-off-by: default avatarKai Ye <yekai13@huawei.com>
Link: https://lore.kernel.org/r/20211206104724.11559-1-yekai13@huawei.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJiangShui Yang <yangjiangshui@h-partners.com>
parent 0274ba70
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -729,7 +729,7 @@ static ssize_t api_show(struct device *dev,
{
	struct uacce_device *uacce = to_uacce_device(dev);

	return sprintf(buf, "%s\n", uacce->api_ver);
	return sysfs_emit(buf, "%s\n", uacce->api_ver);
}

static ssize_t flags_show(struct device *dev,
@@ -737,7 +737,7 @@ static ssize_t flags_show(struct device *dev,
{
	struct uacce_device *uacce = to_uacce_device(dev);

	return sprintf(buf, "%u\n", uacce->flags);
	return sysfs_emit(buf, "%u\n", uacce->flags);
}

static ssize_t available_instances_show(struct device *dev,
@@ -749,7 +749,7 @@ static ssize_t available_instances_show(struct device *dev,
	if (!uacce->ops->get_available_instances)
		return -ENODEV;

	return sprintf(buf, "%d\n",
	return sysfs_emit(buf, "%d\n",
		       uacce->ops->get_available_instances(uacce));
}

@@ -758,7 +758,7 @@ static ssize_t algorithms_show(struct device *dev,
{
	struct uacce_device *uacce = to_uacce_device(dev);

	return sprintf(buf, "%s\n", uacce->algs);
	return sysfs_emit(buf, "%s\n", uacce->algs);
}

static ssize_t region_mmio_size_show(struct device *dev,
@@ -766,7 +766,7 @@ static ssize_t region_mmio_size_show(struct device *dev,
{
	struct uacce_device *uacce = to_uacce_device(dev);

	return sprintf(buf, "%lu\n",
	return sysfs_emit(buf, "%lu\n",
		       uacce->qf_pg_num[UACCE_QFRT_MMIO] << PAGE_SHIFT);
}

@@ -775,7 +775,7 @@ static ssize_t region_dus_size_show(struct device *dev,
{
	struct uacce_device *uacce = to_uacce_device(dev);

	return sprintf(buf, "%lu\n",
	return sysfs_emit(buf, "%lu\n",
		       uacce->qf_pg_num[UACCE_QFRT_DUS] << PAGE_SHIFT);
}