From: Yang Zi <2959243019@qq.com>
To: lgirdwood@gmail.com, broonie@kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] regulator: max8660: Fix NULL pointer dereference in probe
Date: Tue, 25 Aug 2026 16:58:59 +0800 [thread overview]
Message-ID: <tencent_7AEB516C2A94CD5BE16C6C06295527FBC005@qq.com> (raw)
max8660_probe() dereferences pdata->num_subdevs without first checking
that platform data is available. When the device is instantiated without
a device tree node and without platform data, pdata remains NULL and probe
crashes with a NULL pointer dereference.
Add a check after the platform data is resolved and return -ENODEV when
pdata is NULL.
Signed-off-by: Yang Zi <2959243019@qq.com>
---
drivers/regulator/max8660.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
index ede17099b727..ae606067df2d 100644
--- a/drivers/regulator/max8660.c
+++ b/drivers/regulator/max8660.c
@@ -396,6 +396,9 @@ static int max8660_probe(struct i2c_client *client)
memset(of_node, 0, sizeof(of_node));
}
+ if (!pdata)
+ return -ENODEV;
+
if (pdata->num_subdevs > MAX8660_V_END) {
dev_err(dev, "Too many regulators found!\n");
return -EINVAL;
next reply other threads:[~2026-08-25 8:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 8:58 Yang Zi [this message]
2026-08-26 13:31 ` Mark Brown
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_7AEB516C2A94CD5BE16C6C06295527FBC005@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®