Skip to contentSkip to conversation

button: qcom-pmic: Fix dereference of uninitialised pointer

PATCH Applied Andrew Goodbody 2 participants 4 messages Jul 23, 2025 – Aug 18, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 button: qcom-pmic: Fix dereference of uninitialised pointer

The pointer 'label' is declared and later dereferenced without ever having a value assigned to it. Add an assignment to this pointer so it will be valid later when dereferenced.

This issue was found by Smatch.

---
 drivers/button/button-qcom-pmic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/button/button-qcom-pmic.c +2 -1
index 85addfe32a2..b823490d6d5 100644
@@ -195,8 +195,9 @@ static int button_qcom_pmic_bind(struct udevice *parent)
 			continue;
 		}
 
+		label = ofnode_get_name(node);
 		ret = device_bind_driver_to_node(parent, "qcom_pwrkey",
-						 ofnode_get_name(node),
+						 label,
 						 node, &dev);
 		if (ret) {
 			printf("Failed to bind %s! %d\n", label, ret);

---
base-commit: bd0ade7d090a334b3986936d63a34001d99722ad
change-id: 20250723-button-qcom-pmic-882cb5415dd6

Best regards,

Signature · 1 line
Andrew Goodbody <[email protected]>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Andrew Goodbody

The pointer 'label' is declared and later dereferenced without ever having a value assigned to it. Add an assignment to this pointer so it will be valid later when dereferenced.

This issue was found by Smatch.

Quoted 25 lines
---
 drivers/button/button-qcom-pmic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/button/button-qcom-pmic.c +2 -2
index 85addfe32a2..b823490d6d5 100644
@@ -195,8 +195,9 @@ static int button_qcom_pmic_bind(struct udevice *parent)
 			continue;
 		}
 
+		label = ofnode_get_name(node);
 		ret = device_bind_driver_to_node(parent, "qcom_pwrkey",
-						 ofnode_get_name(node),
+						 label,
 						 node, &dev);
 		if (ret) {
 			printf("Failed to bind %s! %d\n", label, ret);
 
---

base-commit: bd0ade7d090a334b3986936d63a34001d99722ad
change-id: 20250723-button-qcom-pmic-882cb5415dd6

Best regards,

Signature · 1 line
// Casey (she/her)
#2 lore raw
Quoted 33 lines · Casey Connolly
Quoted 7 lines · Andrew Goodbody

The pointer 'label' is declared and later dereferenced without ever having a value assigned to it. Add an assignment to this pointer so it will be valid later when dereferenced.

This issue was found by Smatch.

Quoted 20 lines
---
  drivers/button/button-qcom-pmic.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/button/button-qcom-pmic.c +2 -1
index 85addfe32a2..b823490d6d5 100644
@@ -195,8 +195,9 @@ static int button_qcom_pmic_bind(struct udevice *parent)
  			continue;
  		}
 
+		label = ofnode_get_name(node);
  		ret = device_bind_driver_to_node(parent, "qcom_pwrkey",
-						 ofnode_get_name(node),
+						 label,
  						 node, &dev);
  		if (ret) {
  			printf("Failed to bind %s! %d\n", label, ret);
Quoted 6 lines
Quoted 5 lines

---
base-commit: bd0ade7d090a334b3986936d63a34001d99722ad
change-id: 20250723-button-qcom-pmic-882cb5415dd6

Best regards,

Is there anything else needed before this can be merged please?

Thanks,
Andrew

#3 lore raw
In reply to Andrew Goodbody
Quoted 8 lines · Andrew Goodbody

The pointer 'label' is declared and later dereferenced without ever having a value assigned to it. Add an assignment to this pointer so it will be valid later when dereferenced.

This issue was found by Smatch.

[...]

Applied, thanks!

[1/1] button: qcom-pmic: Fix dereference of uninitialised pointer

      https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/commit/8a0bb0b17606

Best regards,

Signature · 1 line
// Caleb (they/them)