diff options
author | Kunwu Chan <chentao@kylinos.cn> | 2023-12-04 17:24:43 +0800 |
---|---|---|
committer | Lee Jones <lee@kernel.org> | 2023-12-07 16:05:11 +0000 |
commit | 41673c66b3d0c09915698fec5c13b24336f18dd1 (patch) | |
tree | a177c10e3af7fb3b4fdc13529183c0ea1f31364c | |
parent | 0c679fffd67605a2c10a61a9a09890970eae11a9 (diff) | |
download | lwn-41673c66b3d0c09915698fec5c13b24336f18dd1.tar.gz lwn-41673c66b3d0c09915698fec5c13b24336f18dd1.zip |
mfd: syscon: Fix null pointer dereference in of_syscon_register()
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 <chentao@kylinos.cn>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20231204092443.2462115-1-chentao@kylinos.cn
Signed-off-by: Lee Jones <lee@kernel.org>
-rw-r--r-- | drivers/mfd/syscon.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c index 57b29c325131..c9550368d9ea 100644 --- a/drivers/mfd/syscon.c +++ b/drivers/mfd/syscon.c @@ -105,6 +105,10 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_res) } 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; |