[PATCH 1/4] crypto: hisilicon/qm - clear runtime PM flag for non-power-manageable device
From: Weili Qian
Date: Thu Sep 24 2026 - 07:42:29 EST
ACPI_COMPANION() may return NULL on firmware without ACPI support.
Passing it directly to acpi_device_power_manageable() causes a NULL
pointer dereference.
Store the companion in a local variable and check it before use.
When the device is not power manageable, clear QM_SUPPORT_RPM so the
driver skips the suspend/resume path.
Fixes: 3e1d2c52b2045 ("crypto: hisilicon - check _PS0 and _PR0 method")
Signed-off-by: Weili Qian <qianweili@xxxxxxxxxx>
---
drivers/crypto/hisilicon/qm.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c
index c01966a4a33f..4f555912f5fc 100644
--- a/drivers/crypto/hisilicon/qm.c
+++ b/drivers/crypto/hisilicon/qm.c
@@ -3158,6 +3158,7 @@ static int hisi_qp_memory_init(struct hisi_qm *qm, size_t dma_size, int id,
static void hisi_qm_pre_init(struct hisi_qm *qm)
{
struct pci_dev *pdev = qm->pdev;
+ struct acpi_device *adev;
if (qm->ver == QM_HW_V1)
qm->ops = &qm_hw_ops_v1;
@@ -3173,9 +3174,16 @@ static void hisi_qm_pre_init(struct hisi_qm *qm)
mutex_init(&qm->ifc_lock);
init_rwsem(&qm->qps_lock);
qm->qp_in_used = 0;
+ /*
+ * If the device is not power manageable, clear the flag to
+ * avoid entering the suspend and resume process later.
+ */
if (test_bit(QM_SUPPORT_RPM, &qm->caps)) {
- if (!acpi_device_power_manageable(ACPI_COMPANION(&pdev->dev)))
- dev_info(&pdev->dev, "_PS0 and _PR0 are not defined");
+ adev = ACPI_COMPANION(&pdev->dev);
+ if (!adev || !acpi_device_power_manageable(adev)) {
+ dev_warn(&pdev->dev, "device does not support runtime power gating\n");
+ clear_bit(QM_SUPPORT_RPM, &qm->caps);
+ }
}
}
--
2.43.0