[PATCH 09/10] regulator: max8907: Avoid NULL idata dereference in max8907_regulator_probe()
From: Lee Jones
Date: Wed Nov 04 2026 - 13:36:58 EST
When a board does not provide platform data or a Device Tree node for
BBAT, SDBY, or VRTC, idata is NULL in max8907_regulator_probe(). Unlike
the MAX8907_MBATT case above it, the BBAT/SDBY/VRTC case unconditionally
dereferences idata to assign idata->supply_regulator, causing a NULL
pointer dereference during probe.
Check that idata is non-NULL before dereferencing it.
Fixes: ffee19091a4e ("regulator: add MAX8907 driver")
Fixes: 5fc72f57e62e ("regulator: max8907: fix use of possibly NULL idata")
Closes: https://sashiko.dev/#/bug/linux-372cd4b4-65df-47bd-8b31-5a7b416b2f91
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/regulator/max8907-regulator.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/regulator/max8907-regulator.c b/drivers/regulator/max8907-regulator.c
index e59aa7a3ee54..ee7d9b7ef7fc 100644
--- a/drivers/regulator/max8907-regulator.c
+++ b/drivers/regulator/max8907-regulator.c
@@ -331,7 +331,8 @@ static int max8907_regulator_probe(struct platform_device *pdev)
case MAX8907_BBAT:
case MAX8907_SDBY:
case MAX8907_VRTC:
- idata->supply_regulator = mbatt_rail_name;
+ if (idata)
+ idata->supply_regulator = mbatt_rail_name;
break;
}
--
2.56.0.385.gac671c819a-goog