drivers/regulator/max8649.c | 3 +++ 1 file changed, 3 insertions(+)
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@qq.com>
---
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:
… > 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
On Wed, Aug 26, 2026 at 08:36:29PM +0200, Markus Elfring wrote: > … > > 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.
On Wed, 26 Aug 2026, Mark Brown wrote: > On Wed, Aug 26, 2026 at 08:36:29PM +0200, Markus Elfring wrote: > > … > > > 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
On Tue, Aug 25, 2026 at 05:01:15PM +0800, Yang Zi wrote: > 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.
© 2016 - 2026 Red Hat, Inc.