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 <[email protected]> Reviewed-by: Arnd Bergmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 0c679ff commit 41673c6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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)