Skip to content

Commit

Permalink
regulator: core: use kfree_const() to free space conditionally
Browse files Browse the repository at this point in the history
[ Upstream commit dc8d006 ]

Use kfree_const() to free supply_name conditionally in create_regulator()
as supply_name may be allocated from kmalloc() or directly from .rodata
section.

Fixes: 87fe29b ("regulator: push allocations in create_regulator() outside of lock")
Signed-off-by: Wang ShaoBo <bobo.shaobowang@huawei.com>
Link: https://lore.kernel.org/r/20221123034616.3609537-1-bobo.shaobowang@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Wang ShaoBo authored and gregkh committed Dec 31, 2022
1 parent 83ddd4c commit 55e4479
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1813,7 +1813,7 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,

regulator = kzalloc(sizeof(*regulator), GFP_KERNEL);
if (regulator == NULL) {
kfree(supply_name);
kfree_const(supply_name);
return NULL;
}

Expand Down

0 comments on commit 55e4479

Please sign in to comment.