Skip to content

Commit e3b7649

Browse files
Felix Gubroonie
authored andcommitted
regulator: fp9931: Add missing memory allocation check
Add a check for devm_kzalloc failure in fp9931_probe to prevent a null pointer dereference. Fixes: 12d821b ("regulator: Add FP9931/JD9930 driver") Signed-off-by: Felix Gu <gu_0233@qq.com> Link: https://patch.msgid.link/tencent_5FCF2108621C51007E5526A7C60A5CC1F306@qq.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 24d479d commit e3b7649

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/regulator/fp9931.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,9 @@ static int fp9931_probe(struct i2c_client *client)
439439
int i;
440440

441441
data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
442+
if (!data)
443+
return -ENOMEM;
444+
442445
data->regmap = devm_regmap_init_i2c(client, &regmap_config);
443446
if (IS_ERR(data->regmap))
444447
return dev_err_probe(&client->dev, PTR_ERR(data->regmap),

0 commit comments

Comments
 (0)