Skip to contentSkip to conversation

pinctrl: berlin: fix error return code of berlin_pinctrl_build_state()

PATCH In review Meng Tang 2 participants 2 messages Mar 3, 2022 – Mar 15, 2022

Subsystems (2)
lore
Share & tools
lore

Meng Tang

author
#0 lore raw

PATCH 1/1 pinctrl: berlin: fix error return code of berlin_pinctrl_build_state()

When krealloc() fails and pctrl->functions is NULL, no error return code of berlin_pinctrl_build_state() is assigned. To fix this bug, ret is assigned with -ENOMEM when pctrl->functions is NULL.

---
 drivers/pinctrl/berlin/berlin.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/pinctrl/berlin/berlin.c +2 -0
index b17a03cf87be..a073eedd71aa 100644
@@ -233,6 +233,8 @@ static int berlin_pinctrl_build_state(struct platform_device *pdev)
 	pctrl->functions = krealloc(pctrl->functions,
 				    pctrl->nfunctions * sizeof(*pctrl->functions),
 				    GFP_KERNEL);
+	if (!pctrl->functions)
+		return -ENOMEM;
 
 	/* map functions to theirs groups */
 	for (i = 0; i < pctrl->desc->ngroups; i++) {
Signature · 1 line
2.20.1
#1 lore raw
Quoted 6 lines · Meng Tang

When krealloc() fails and pctrl->functions is NULL, no error return code of berlin_pinctrl_build_state() is assigned. To fix this bug, ret is assigned with -ENOMEM when pctrl->functions is NULL.

Patch applied!

Yours,
Linus Walleij