Skip to content

Commit 310cd4c

Browse files
claudiubeznealinusw
authored andcommitted
pinctrl: microchip-sgpio: check return value of devm_kasprintf()
devm_kasprintf() returns a pointer to dynamically allocated memory. Pointer could be NULL in case allocation fails. Check pointer validity. Identified with coccinelle (kmerr.cocci script). Fixes: 7e5ea97 ("pinctrl: pinctrl-microchip-sgpio: Add pinctrl driver for Microsemi Serial GPIO") Signed-off-by: Claudiu Beznea <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 9063777 commit 310cd4c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/pinctrl/pinctrl-microchip-sgpio.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,9 @@ static int microchip_sgpio_register_bank(struct device *dev,
816816
pctl_desc->name = devm_kasprintf(dev, GFP_KERNEL, "%s-%sput",
817817
dev_name(dev),
818818
bank->is_input ? "in" : "out");
819+
if (!pctl_desc->name)
820+
return -ENOMEM;
821+
819822
pctl_desc->pctlops = &sgpio_pctl_ops;
820823
pctl_desc->pmxops = &sgpio_pmx_ops;
821824
pctl_desc->confops = &sgpio_confops;

0 commit comments

Comments
 (0)