From: Yang Zi <2959243019@qq.com>
To: lgirdwood@gmail.com, broonie@kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] regulator: max8649: Fix NULL pointer dereference in probe
Date: Tue, 25 Aug 2026 17:01:15 +0800 [thread overview]
Message-ID: <tencent_87EA54368697A49844A89DF7CD19CD8C6C06@qq.com> (raw)
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:
next reply other threads:[~2026-08-25 9:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 9:01 Yang Zi [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_87EA54368697A49844A89DF7CD19CD8C6C06@qq.com \
--to=2959243019@qq.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®