[PATCH] power: supply: qcom_smbx: read the charging status without the power supply

From: Fabricio Akio via B4 Relay

Date: Thu Oct 08 2026 - 16:56:55 EST


From: Fabricio Akio <fabricioakio@xxxxxxxxx>

smb_get_iio_chan() reads the charging status through
power_supply_get_property(chip->chg_psy), but chip->chg_psy is assigned
only when devm_power_supply_register() returns, and the power supply
core already calls get_property() from inside the registration, for its
uevents. If another driver has taken a reference to the supply by then,
as a fuel gauge naming the charger in power-supplies does, the core lets
the call through, and reading CURRENT_NOW or VOLTAGE_NOW dereferences
the NULL chg_psy.

Read the status from the hardware with smb_get_prop_status(), as the
STATUS property itself does.

Fixes: 8648aeb5d7b7 ("power: supply: add Qualcomm PMI8998 SMB2 Charger driver")
Signed-off-by: Fabricio Akio <fabricioakio@xxxxxxxxx>
---
drivers/power/supply/qcom_smbx.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/power/supply/qcom_smbx.c b/drivers/power/supply/qcom_smbx.c
index 3951326f488f..6e0796730c59 100644
--- a/drivers/power/supply/qcom_smbx.c
+++ b/drivers/power/supply/qcom_smbx.c
@@ -607,12 +607,10 @@ static void smb_status_change_work(struct work_struct *work)
static int smb_get_iio_chan(struct smb_chip *chip, struct iio_channel *chan,
int *val)
{
- int rc;
- union power_supply_propval status;
+ int rc, status;

- rc = power_supply_get_property(chip->chg_psy, POWER_SUPPLY_PROP_STATUS,
- &status);
- if (rc < 0 || status.intval != POWER_SUPPLY_STATUS_CHARGING) {
+ rc = smb_get_prop_status(chip, &status);
+ if (rc < 0 || status != POWER_SUPPLY_STATUS_CHARGING) {
*val = 0;
return 0;
}

---
base-commit: aac26bee2287c88af5be5a5ff96d783b19a28790
change-id: 20261008-qcom-smbx-psy-race-521568f9cfde

Best regards,
--
Fabricio Akio <fabricioakio@xxxxxxxxx>