Skip to contentSkip to conversation

soc: qcom: pmic_glink_altmode: Fix printing of a fwnode with %pOFn

PATCH In review Asdlerto Korry 2 participants 2 messages Nov 2

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 soc: qcom: pmic_glink_altmode: Fix printing of a fwnode with %pOFn

pmic_glink_altmode_probe() walks the child nodes with device_for_each_child_node(), which yields a struct fwnode_handle, but prints it with %pOFn, which expects a struct device_node. vsprintf then treats the fwnode_handle as a device_node and passes &dn->fwnode to fwnode_get_name(), i.e. a pointer into the middle of the handle, and calls through a garbage fwnode->ops. The error path ("missing reg property") therefore oopses instead of printing the message:

  lr : fwnode_get_name+0x34/0x50
  ...
  device_node_string
  pointer
  vsnprintf
  ...
  pmic_glink_altmode_probe

It was hit on a Samsung Galaxy M52 5G (SM7325) whose vendor device tree has an extra "qcom,pmic-glink" compatible node without a reg property.

Use %pfwP, the specifier for the name of a fwnode.

Fixes 080b4e24852b ("soc: qcom: pmic_glink: Introduce altmode support")
---
 drivers/soc/qcom/pmic_glink_altmode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/qcom/pmic_glink_altmode.c +1 -1
index 465e5d2316a0..6f3737b096cf 100644
@@ -596,7 +596,7 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev,
 	device_for_each_child_node(dev, fwnode) {
 		ret = fwnode_property_read_u32(fwnode, "reg", &port);
 		if (ret < 0) {
-			dev_err(dev, "missing reg property of %pOFn\n", fwnode);
+			dev_err(dev, "missing reg property of %pfwP\n", fwnode);
 			fwnode_handle_put(fwnode);
 			return ret;
 		}
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Asdlerto Korry

pmic_glink_altmode_probe() walks the child nodes with device_for_each_child_node(), which yields a struct fwnode_handle, but prints it with %pOFn, which expects a struct device_node. vsprintf then treats the fwnode_handle as a device_node and passes &dn->fwnode to fwnode_get_name(), i.e. a pointer into the middle of the handle, and calls through a garbage fwnode->ops. The error path ("missing reg property") therefore oopses instead of printing the message:

  lr : fwnode_get_name+0x34/0x50
  ...
  device_node_string
  pointer
  vsnprintf
  ...
  pmic_glink_altmode_probe
Quoted 2 lines

It was hit on a Samsung Galaxy M52 5G (SM7325) whose vendor device tree has an extra "qcom,pmic-glink" compatible node without a reg property.

FWIW Vendor DTs are not supposed to work with the upstream kernel (because they diverge so much from the upstream dt-bindings)>

Quoted 5 lines

Use %pfwP, the specifier for the name of a fwnode.

Fixes 080b4e24852b ("soc: qcom: pmic_glink: Introduce altmode support")

---

But the issue and fix are of course real and valid

Konrad

Quoted 16 lines
 drivers/soc/qcom/pmic_glink_altmode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/qcom/pmic_glink_altmode.c +1 -1
index 465e5d2316a0..6f3737b096cf 100644
@@ -596,7 +596,7 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev,
 	device_for_each_child_node(dev, fwnode) {
 		ret = fwnode_property_read_u32(fwnode, "reg", &port);
 		if (ret < 0) {
-			dev_err(dev, "missing reg property of %pOFn\n", fwnode);
+			dev_err(dev, "missing reg property of %pfwP\n", fwnode);
 			fwnode_handle_put(fwnode);
 			return ret;
 		}