diff mbox series

crypto: qat - prevent underflow in rp2srv_store()

Message ID 3fb31247-5f9c-4dba-a8b7-5d653c6509b6@moroto.mountain (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series crypto: qat - prevent underflow in rp2srv_store() | expand

Commit Message

Dan Carpenter Oct. 31, 2023, 8:58 a.m. UTC
The "ring" variable has an upper bounds check but nothing checks for
negatives.  This code uses kstrtouint() already and it was obviously
intended to be declared as unsigned int.  Make it so.

Fixes: dbc8876dd873 ("crypto: qat - add rp2svc sysfs attribute")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/crypto/intel/qat/qat_common/adf_sysfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Cabiddu, Giovanni Nov. 17, 2023, 9:35 a.m. UTC | #1
On Tue, Oct 31, 2023 at 11:58:32AM +0300, Dan Carpenter wrote:
> The "ring" variable has an upper bounds check but nothing checks for
> negatives.  This code uses kstrtouint() already and it was obviously
> intended to be declared as unsigned int.  Make it so.
> 
> Fixes: dbc8876dd873 ("crypto: qat - add rp2svc sysfs attribute")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>

Regards,
Herbert Xu Nov. 17, 2023, 11:24 a.m. UTC | #2
On Tue, Oct 31, 2023 at 11:58:32AM +0300, Dan Carpenter wrote:
> The "ring" variable has an upper bounds check but nothing checks for
> negatives.  This code uses kstrtouint() already and it was obviously
> intended to be declared as unsigned int.  Make it so.
> 
> Fixes: dbc8876dd873 ("crypto: qat - add rp2svc sysfs attribute")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/crypto/intel/qat/qat_common/adf_sysfs.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Patch applied.  Thanks.
diff mbox series

Patch

diff --git a/drivers/crypto/intel/qat/qat_common/adf_sysfs.c b/drivers/crypto/intel/qat/qat_common/adf_sysfs.c
index ddffc98119c6..6f0b3629da13 100644
--- a/drivers/crypto/intel/qat/qat_common/adf_sysfs.c
+++ b/drivers/crypto/intel/qat/qat_common/adf_sysfs.c
@@ -242,7 +242,8 @@  static ssize_t rp2srv_store(struct device *dev, struct device_attribute *attr,
 			    const char *buf, size_t count)
 {
 	struct adf_accel_dev *accel_dev;
-	int ring, num_rings, ret;
+	int num_rings, ret;
+	unsigned int ring;
 
 	accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev));
 	if (!accel_dev)