[PATCH] regulator: max8649: Fix NULL pointer dereference in probe
From: Yang Zi
Date: Tue Aug 25 2026 - 05:01:28 EST
max8649_regulator_probe() dereferences pdata->mode without first checking
that platform data is available. When the device is instantiated without
platform data, pdata is NULL and probe crashes with a NULL pointer
dereference.
Add a check and return -EINVAL when pdata is NULL.
Signed-off-by: Yang Zi <2959243019@xxxxxx>
---
drivers/regulator/max8649.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/regulator/max8649.c b/drivers/regulator/max8649.c
index 2d17405242e7..7133b0aee889 100644
--- a/drivers/regulator/max8649.c
+++ b/drivers/regulator/max8649.c
@@ -170,6 +170,9 @@ static int max8649_regulator_probe(struct i2c_client *client)
info->dev = &client->dev;
i2c_set_clientdata(client, info);
+ if (!pdata)
+ return -EINVAL;
+
info->mode = pdata->mode;
switch (info->mode) {
case 0: