Skip to content

Commit 41673c6

Browse files
KunWuChanlag-linaro
authored andcommitted
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: e15d7f2 ("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>
1 parent 0c679ff commit 41673c6

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

drivers/mfd/syscon.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_res)
105105
}
106106

107107
syscon_config.name = kasprintf(GFP_KERNEL, "%pOFn@%pa", np, &res.start);
108+
if (!syscon_config.name) {
109+
ret = -ENOMEM;
110+
goto err_regmap;
111+
}
108112
syscon_config.reg_stride = reg_io_width;
109113
syscon_config.val_bits = reg_io_width * 8;
110114
syscon_config.max_register = resource_size(&res) - reg_io_width;

0 commit comments

Comments
 (0)