* [PATCH] regulator: max8660: Fix NULL pointer dereference in probe
@ 2026-08-25 8:58 Yang Zi
2026-08-26 13:31 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Yang Zi @ 2026-08-25 8:58 UTC (permalink / raw)
To: lgirdwood, broonie; +Cc: linux-kernel
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;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] regulator: max8660: Fix NULL pointer dereference in probe
2026-08-25 8:58 [PATCH] regulator: max8660: Fix NULL pointer dereference in probe Yang Zi
@ 2026-08-26 13:31 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2026-08-26 13:31 UTC (permalink / raw)
To: Yang Zi; +Cc: lgirdwood, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 392 bytes --]
On Tue, Aug 25, 2026 at 04:58:59PM +0800, Yang Zi wrote:
> 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.
This doesn't apply against current code, please check and resend.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-26 13:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-25 8:58 [PATCH] regulator: max8660: Fix NULL pointer dereference in probe Yang Zi
2026-08-26 13:31 ` Mark Brown
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®