Re: crypto: hisilicon - Fix sscanf format signedness
From: Joe Perches
Date: Fri Aug 27 2021 - 15:33:48 EST
On Fri, 2021-08-27 at 16:43 +0800, Herbert Xu wrote:
> The function qm_qos_value_init expects an unsigned integer but
> is incorrectly supplying a signed format to sscanf. This patch
> fixes it.
[]
> diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c
[]
> @@ -4191,7 +4191,7 @@ static ssize_t qm_qos_value_init(const char *buf, unsigned long *val)
> return -EINVAL;
> }
>
>
> - ret = sscanf(buf, "%ld", val);
> + ret = sscanf(buf, "%lu", val);
> if (ret != QM_QOS_VAL_NUM)
> return -EINVAL;
QM_QOS_VAL_NUM seems an especially silly define
A direct use of 1 would be _far_ better IMO.
$ git grep -w -n QM_QOS_VAL_NUM
drivers/crypto/hisilicon/qm.c:246:#define QM_QOS_VAL_NUM 1
drivers/crypto/hisilicon/qm.c:4189: if (ret != QM_QOS_VAL_NUM)