mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] regulator: max8649: Fix NULL pointer dereference in probe
@ 2026-08-25  9:01 Yang Zi
  2026-08-26 13:34 ` Mark Brown
  2026-08-26 18:36 ` Markus Elfring
  0 siblings, 2 replies; 5+ messages in thread
From: Yang Zi @ 2026-08-25  9:01 UTC (permalink / raw)
  To: lgirdwood, broonie; +Cc: linux-kernel

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:



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-26 19:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-25  9:01 [PATCH] regulator: max8649: Fix NULL pointer dereference in probe Yang Zi
2026-08-26 13:34 ` Mark Brown
2026-08-26 18:36 ` Markus Elfring
2026-08-26 18:39   ` Mark Brown
2026-08-26 18:58     ` Robert P. J. Day

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®