2023-11-28 20:38:04

by Cabiddu, Giovanni

[permalink] [raw]
Subject: [PATCH] crypto: qat - add NULL pointer check

There is a possibility that the function adf_devmgr_pci_to_accel_dev()
might return a NULL pointer.
Add a NULL pointer check in the function rp2srv_show().

Fixes: dbc8876dd873 ("crypto: qat - add rp2svc sysfs attribute")
Signed-off-by: Giovanni Cabiddu <[email protected]>
Reviewed-by: Ahsan Atta <[email protected]>
Reviewed-by: David Guckian <[email protected]>
---
drivers/crypto/intel/qat/qat_common/adf_sysfs.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/crypto/intel/qat/qat_common/adf_sysfs.c b/drivers/crypto/intel/qat/qat_common/adf_sysfs.c
index 6f0b3629da13..d450dad32c9e 100644
--- a/drivers/crypto/intel/qat/qat_common/adf_sysfs.c
+++ b/drivers/crypto/intel/qat/qat_common/adf_sysfs.c
@@ -215,6 +215,9 @@ static ssize_t rp2srv_show(struct device *dev, struct device_attribute *attr,
enum adf_cfg_service_type svc;

accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev));
+ if (!accel_dev)
+ return -EINVAL;
+
hw_data = GET_HW_DATA(accel_dev);

if (accel_dev->sysfs.ring_num == UNSET_RING_NUM)
--
2.42.0



2023-12-08 04:34:35

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: qat - add NULL pointer check

On Tue, Nov 28, 2023 at 07:17:25PM +0000, Giovanni Cabiddu wrote:
> There is a possibility that the function adf_devmgr_pci_to_accel_dev()
> might return a NULL pointer.
> Add a NULL pointer check in the function rp2srv_show().
>
> Fixes: dbc8876dd873 ("crypto: qat - add rp2svc sysfs attribute")
> Signed-off-by: Giovanni Cabiddu <[email protected]>
> Reviewed-by: Ahsan Atta <[email protected]>
> Reviewed-by: David Guckian <[email protected]>
> ---
> drivers/crypto/intel/qat/qat_common/adf_sysfs.c | 3 +++
> 1 file changed, 3 insertions(+)

Patch applied. Thanks.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt