lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c9e11594e7edbbf8ee0a01a5009457a2c4a79ffc.camel@perches.com>
Date:   Sun, 05 Dec 2021 23:18:27 -0800
From:   Joe Perches <joe@...ches.com>
To:     Kai Ye <yekai13@...wei.com>, gregkh@...uxfoundation.org,
        linux-accelerators@...ts.ozlabs.org, linux-kernel@...r.kernel.org,
        linuxarm@...wei.com, zhangfei.gao@...aro.org,
        wangzhou1@...ilicon.com
Subject: Re: [PATCH v2] uacce: use sysfs_emit instead of sprintf

On Mon, 2021-12-06 at 15:09 +0800, Kai Ye wrote:
> 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.
[]
> diff --git a/drivers/misc/uacce/uacce.c b/drivers/misc/uacce/uacce.c
[]
> @@ -309,7 +309,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));

It's generally good form to rewrap the multiple line statements
to the open parenthesis so the below would be better:

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

> @@ -326,7 +326,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);

etc...


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ