From: Eric-Terminal <ericterminal@gmail.com>
To: Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>
Cc: linux-kernel@vger.kernel.org, Eric-Terminal <ericterminal@gmail.com>
Subject: [PATCH] regulator: tps65185: check devm_kzalloc() result in probe
Date: Sat, 21 Feb 2026 15:17:28 +0800 [thread overview]
Message-ID: <20260221071728.23761-1-ericterminal@gmail.com> (raw)
tps65185_probe() dereferences the allocation result immediately by using data->regmap. If devm_kzalloc() returns NULL under memory pressure, this leads to a NULL pointer dereference.
Add the missing allocation check and return -ENOMEM on failure.
Signed-off-by: Eric-Terminal <ericterminal@gmail.com>
---
drivers/regulator/tps65185.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/regulator/tps65185.c b/drivers/regulator/tps65185.c
index 3286c9ab3..786622d8d 100644
--- a/drivers/regulator/tps65185.c
+++ b/drivers/regulator/tps65185.c
@@ -332,6 +332,9 @@ static int tps65185_probe(struct i2c_client *client)
int i;
data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
+
data->regmap = devm_regmap_init_i2c(client, ®map_config);
if (IS_ERR(data->regmap))
return dev_err_probe(&client->dev, PTR_ERR(data->regmap),
--
2.47.3
next reply other threads:[~2026-02-21 7:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-21 7:17 Eric-Terminal [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-02-22 10:40 [PATCH] regulator: tps65185: check devm_kzalloc() result in probe Yufan Chen
2026-02-22 10:51 ` Eric_Terminal
2026-02-23 19:09 ` 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=20260221071728.23761-1-ericterminal@gmail.com \
--to=ericterminal@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.