Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Yufan Chen and committed by
Mark Brown
4b73231b be704107

+3
+3
drivers/regulator/tps65185.c
··· 332 332 int i; 333 333 334 334 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); 335 + if (!data) 336 + return -ENOMEM; 337 + 335 338 data->regmap = devm_regmap_init_i2c(client, &regmap_config); 336 339 if (IS_ERR(data->regmap)) 337 340 return dev_err_probe(&client->dev, PTR_ERR(data->regmap),