crypto: qat - add NULL pointer check
authorGiovanni Cabiddu <giovanni.cabiddu@intel.com>
Tue, 28 Nov 2023 19:17:25 +0000 (19:17 +0000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 8 Dec 2023 03:59:44 +0000 (11:59 +0800)
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 <giovanni.cabiddu@intel.com>
Reviewed-by: Ahsan Atta <ahsan.atta@intel.com>
Reviewed-by: David Guckian <david.guckian@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/intel/qat/qat_common/adf_sysfs.c

index 6f0b3629da13d208d760bbbe4e6692b3ff0fce9b..d450dad32c9e4e9be3ad635855ee2c58ab4819f6 100644 (file)
@@ -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)