Skip to contentSkip to conversation

soc: qcom: aoss: avoid registering cooling for NULL cdev

PATCH NAK Haris Wu 2 participants 2 messages Dec 12, 2025

Subsystems (2)
lore
Share & tools
lore

Haris Wu

author
#0 lore raw

PATCH 1/1 soc: qcom: aoss: avoid registering cooling for NULL cdev

When PTR_ERR_OR_ZERO points to NULL, it returns 0. In this case, if (ret) does not meet expectations. Now, qmp_cooling_device_add returns NODEV for both failure and NULL, and returns 0 for success.

---
 drivers/soc/qcom/qcom_aoss.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/soc/qcom/qcom_aoss.c +4 -2
index a543ab9be..ac411343d 100644
@@ -386,11 +386,13 @@ static int qmp_cooling_device_add(struct qmp *qmp,
 				cdev_name,
 				qmp_cdev, &qmp_cooling_device_ops);
 
-	if (IS_ERR(qmp_cdev->cdev))
+	if (IS_ERR_OR_NULL(qmp_cdev->cdev)) {
 		dev_err(qmp->dev, "unable to register %s cooling device\n",
 			cdev_name);
+		return -ENODEV;
+	}
 
-	return PTR_ERR_OR_ZERO(qmp_cdev->cdev);
+	return 0;
 }
 
 static int qmp_cooling_devices_register(struct qmp *qmp)
Signature · 1 line
2.47.3
#1 lore raw
Quoted 8 lines · Haris Wu

When PTR_ERR_OR_ZERO points to NULL, it returns 0. In this case, if (ret) does not meet expectations. Now, qmp_cooling_device_add returns NODEV for both failure and NULL, and returns 0 for success.

---
 drivers/soc/qcom/qcom_aoss.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

NAK, devm_thermal_of_cooling_device_register() can't return NULL. It returns either a valid device pointer or an error pointer.

Quoted 24 lines
drivers/soc/qcom/qcom_aoss.c +4 -2
index a543ab9be..ac411343d 100644
@@ -386,11 +386,13 @@ static int qmp_cooling_device_add(struct qmp *qmp,
 				cdev_name,
 				qmp_cdev, &qmp_cooling_device_ops);
 
-	if (IS_ERR(qmp_cdev->cdev))
+	if (IS_ERR_OR_NULL(qmp_cdev->cdev)) {
 		dev_err(qmp->dev, "unable to register %s cooling device\n",
 			cdev_name);
+		return -ENODEV;
+	}
 
-	return PTR_ERR_OR_ZERO(qmp_cdev->cdev);
+	return 0;
 }
 
 static int qmp_cooling_devices_register(struct qmp *qmp)
Signature · 1 line
2.47.3
Signature · 2 lines
With best wishes
Dmitry