On Wed, 2021-01-20 at 15:22 +0800, Jiapeng Zhong wrote:
> Fix the following coccicheck warning:
> 
> ./drivers/scsi/qla4xxx/ql4_attr.c: WARNING: use scnprintf or
> sprintf
> 
> The snprintf() function returns the number of characters which would
> have been printed if there were enough space, but the scnprintf()
> returns the number of characters which were actually printed.  If
> the buffer is not large enough, then using snprintf() would result
> in a read overflow and an information leak.
> 
> Reported-by: Abaci Robot<ab...@linux.alibaba.com>
> Signed-off-by: Jiapeng Zhong <abaci-bug...@linux.alibaba.com>
> ---
>  drivers/scsi/qla4xxx/ql4_attr.c | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/scsi/qla4xxx/ql4_attr.c
> b/drivers/scsi/qla4xxx/ql4_attr.c
> index ec43528..1a16017 100644
> --- a/drivers/scsi/qla4xxx/ql4_attr.c
> +++ b/drivers/scsi/qla4xxx/ql4_attr.c
> @@ -170,7 +170,7 @@ void qla4_8xxx_free_sysfs_attr(struct
> scsi_qla_host *ha)
>                       char *buf)
>  {
>       struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
> -     return snprintf(buf, PAGE_SIZE, "%s\n", ha->serial_number);
> +     return scnprintf(buf, PAGE_SIZE, "%s\n", ha->serial_number);

This is the wrong ABI to be replacing anything sysfs with, it should be
sysfs_emit()

James


Reply via email to