Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 49af64e6 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Linus Walleij
Browse files

pinctrl: imx: Check for memory allocation failure



If 'devm_kzalloc' fails, a NULL pointer will be dereferenced.
Return -ENOMEM instead, as done for the other memory allocation just a
few lines below.
BTW, change the 'devm_kzalloc' into a 'devm_kcalloc'.

Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent ceba4383
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -581,9 +581,10 @@ static int imx_pinctrl_parse_functions(struct device_node *np,
		dev_err(info->dev, "no groups defined in %s\n", np->full_name);
		dev_err(info->dev, "no groups defined in %s\n", np->full_name);
		return -EINVAL;
		return -EINVAL;
	}
	}
	func->group_names = devm_kzalloc(info->dev,
	func->group_names = devm_kcalloc(info->dev, func->num_group_names,
					 func->num_group_names *
					 sizeof(char *), GFP_KERNEL);
					 sizeof(char *), GFP_KERNEL);
	if (!func->group_names)
		return -ENOMEM;


	for_each_child_of_node(np, child) {
	for_each_child_of_node(np, child) {
		func->group_names[i] = child->name;
		func->group_names[i] = child->name;