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 15:27:44 -0800
commit527e8c5f3d00299822612c495d5adf1f8f43c001 (patch)
tree04e7109beca495a1fbd000c6f54efb81ed89cd15
parentac3b65cbc68deeabc6100e7bac254416675a7052 (diff)
downloadlinux-527e8c5f3d00299822612c495d5adf1f8f43c001.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 bdb2ce7ff03b9d..6196724ef39bb7 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -102,6 +102,10 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_clk)
}
syscon_config.name = kasprintf(GFP_KERNEL, "%pOFn@%pa", np, &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;