Skip to contentSkip to conversation

regulator: max8649: Fix NULL pointer dereference in probe

PATCH In review Yang Zi 4 participants 5 messages Aug 25 – Aug 26

Subsystems (2)
lore
Share & tools
lore

Yang Zi

author
#0 lore raw

PATCH 1/1 regulator: max8649: Fix NULL pointer dereference in probe

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.

---
 drivers/regulator/max8649.c | 3 +++

 1 file changed, 3 insertions(+)
drivers/regulator/max8649.c +0 -0
index 2d17405242e7..7133b0aee889 100644
@@ -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:

maintainer
#1 lore raw
Quoted 4 lines · Yang Zi

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.

This doesn't apply against curent code, please check and resend.

#2 lore raw
In reply to Yang Zi

…

Quoted 1 line

Add a check and return -EINVAL when pdata is NULL.

How do you think about to perform this data processing directly after the variable assignment?

Regards,
Markus

maintainer
#3 lore raw
Quoted 5 lines · Markus Elfring

…

Quoted 1 line

Add a check and return -EINVAL when pdata is NULL.

How do you think about to perform this data processing directly after the variable assignment?

Feel free to ignore Markus, he has a long history of sending unhelpful review comments and continues to ignore repeated requests to stop.

#4 lore raw
Quoted 10 lines · Mark Brown
Quoted 5 lines · Markus Elfring

…

Quoted 1 line

Add a check and return -EINVAL when pdata is NULL.

How do you think about to perform this data processing directly after the variable assignment?

Feel free to ignore Markus, he has a long history of sending unhelpful review comments and continues to ignore repeated requests to stop.

I've recently wondered how easy it would be to write a "Markus
Elfring Random Suggestion Generator".

rday