[PATCH] regulator: max8660: Fix NULL pointer dereference in probe
From: Yang Zi
Date: Tue Aug 25 2026 - 05:01:45 EST
max8660_probe() dereferences pdata->num_subdevs without first checking
that platform data is available. When the device is instantiated without
a device tree node and without platform data, pdata remains NULL and probe
crashes with a NULL pointer dereference.
Add a check after the platform data is resolved and return -ENODEV when
pdata is NULL.
Signed-off-by: Yang Zi <2959243019@xxxxxx>
---
drivers/regulator/max8660.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
index ede17099b727..ae606067df2d 100644
--- a/drivers/regulator/max8660.c
+++ b/drivers/regulator/max8660.c
@@ -396,6 +396,9 @@ static int max8660_probe(struct i2c_client *client)
memset(of_node, 0, sizeof(of_node));
}
+ if (!pdata)
+ return -ENODEV;
+
if (pdata->num_subdevs > MAX8660_V_END) {
dev_err(dev, "Too many regulators found!\n");
return -EINVAL;