[PATCH] regulator: fp9931: Add missing memory allocation check

Felix Gu posted 1 patch 2 weeks, 5 days ago
drivers/regulator/fp9931.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] regulator: fp9931: Add missing memory allocation check
Posted by Felix Gu 2 weeks, 5 days ago
Add a check for devm_kzalloc failure in fp9931_probe to prevent a
null pointer dereference.

Fixes: 12d821bd13d4 ("regulator: Add FP9931/JD9930 driver")
Signed-off-by: Felix Gu <gu_0233@qq.com>
---
 drivers/regulator/fp9931.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/regulator/fp9931.c b/drivers/regulator/fp9931.c
index 69b3c712e5d5..7fbcc6327cc6 100644
--- a/drivers/regulator/fp9931.c
+++ b/drivers/regulator/fp9931.c
@@ -439,6 +439,9 @@ static int fp9931_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),

---
base-commit: 46fe65a2c28ecf5df1a7475aba1f08ccf4c0ac1b
change-id: 20260118-fp9931-60bbc1e8a351

Best regards,
-- 
Felix Gu <gu_0233@qq.com>
Re: [PATCH] regulator: fp9931: Add missing memory allocation check
Posted by Mark Brown 2 weeks, 3 days ago
On Sun, 18 Jan 2026 17:26:23 +0800, Felix Gu wrote:
> Add a check for devm_kzalloc failure in fp9931_probe to prevent a
> null pointer dereference.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[1/1] regulator: fp9931: Add missing memory allocation check
      commit: e3b76494d675e49fa032ec47f58487875a1de70a

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark