aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKunwu Chan <[email protected]>2023-12-04 17:24:43 +0800
committerGreg Kroah-Hartman <[email protected]>2024-01-25 14:37:53 -0800
commit927626a2073887ee30ba00633260d4d203f8e875 (patch)
tree0ed35c38a7ba0da840cf7739123fd27cb35f017c
parentc964a0597b50806c568ad4f04205cccd4bbac8b9 (diff)
downloadlinux-927626a2073887ee30ba00633260d4d203f8e875.tar.gz
mfd: syscon: Fix null pointer dereference in of_syscon_register()
[ Upstream commit 41673c66b3d0c09915698fec5c13b24336f18dd1 ] kasprintf() returns a pointer to dynamically allocated memory which can be NULL upon failure. Fixes: e15d7f2b81d2 ("mfd: syscon: Use a unique name with regmap_config") Signed-off-by: Kunwu Chan <[email protected]> Reviewed-by: Arnd Bergmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
-rw-r--r--drivers/mfd/syscon.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index df5cebb372a592..60f74144a4f88e 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -103,6 +103,10 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_clk)
syscon_config.name = kasprintf(GFP_KERNEL, "%pOFn@%llx", np,
(u64)res.start);
+ if (!syscon_config.name) {
+ ret = -ENOMEM;
+ goto err_regmap;
+ }
syscon_config.reg_stride = reg_io_width;
syscon_config.val_bits = reg_io_width * 8;
syscon_config.max_register = resource_size(&res) - reg_io_width;