summaryrefslogtreecommitdiff
path: root/drivers/regulator
diff options
context:
space:
mode:
authorYufan Chen <ericterminal@gmail.com>2026-02-22 18:40:35 +0800
committerMark Brown <broonie@kernel.org>2026-02-23 14:52:16 +0000
commit4b73231b2a61c4142a027613d277a19c484dfcc3 (patch)
treef80fee5f9709195f2a899c4957aa50c7e5652f4c /drivers/regulator
parentbe704107e79696e855aa41e901a926039b6d2410 (diff)
downloadlinux-next-4b73231b2a61c4142a027613d277a19c484dfcc3.tar.gz
linux-next-4b73231b2a61c4142a027613d277a19c484dfcc3.zip
regulator: tps65185: check devm_kzalloc() result in probe
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: Yufan Chen <ericterminal@gmail.com> Link: https://patch.msgid.link/20260222104035.90790-1-ericterminal@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/tps65185.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/regulator/tps65185.c b/drivers/regulator/tps65185.c
index 3286c9ab33d0..786622d8d598 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, &regmap_config);
if (IS_ERR(data->regmap))
return dev_err_probe(&client->dev, PTR_ERR(data->regmap),