From: Wang ShaoBo Date: Wed, 23 Nov 2022 03:46:16 +0000 (+0800) Subject: regulator: core: use kfree_const() to free space conditionally X-Git-Tag: baikal/aarch64/sdk5.9~672 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=49bab93ced8c794ff161306b0f62dc6a7a731b16;p=kernel.git regulator: core: use kfree_const() to free space conditionally [ Upstream commit dc8d006d15b623c1d80b90b45d6dcb6e890dad09 ] 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: 9104bbc1abe9 ("regulator: push allocations in create_regulator() outside of lock") Signed-off-by: Wang ShaoBo Link: https://lore.kernel.org/r/20221123034616.3609537-1-bobo.shaobowang@huawei.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index ee71dcb009bf7..9b4783bf63f74 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1604,7 +1604,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; }