regulator: max8649: Fix NULL pointer dereference in probe
Subsystems (2)
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
@@ -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:
Mark Brown
maintainerQuoted 4 lines · Yang Zi
max8649_regulator_probe()dereferencespdata->modewithout 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.
…
Quoted 1 line
Add a check and return
-EINVALwhen pdata is NULL.
How do you think about to perform this data processing directly after the variable assignment?
Regards,
Markus
Mark Brown
maintainerQuoted 5 lines · Markus Elfring
…
Quoted 1 line
Add a check and return
-EINVALwhen 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.
Quoted 10 lines · Mark Brown
Quoted 5 lines · Markus Elfring
…
Quoted 1 line
Add a check and return
-EINVALwhen 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