summaryrefslogtreecommitdiff
path: root/drivers/pinctrl/berlin/berlin.c
diff options
context:
space:
mode:
authorMeng Tang <tangmeng@uniontech.com>2022-03-03 11:02:06 +0300
committerLinus Walleij <linus.walleij@linaro.org>2022-03-15 04:18:57 +0300
commitde845036f997119bcacbdb7b4ccf3b6cf960745b (patch)
treeb9e4a0f7e3d3eae63baa43ff41a7ab41876efac4 /drivers/pinctrl/berlin/berlin.c
parentc0e4c71a9e7ceea8f14e0b875fcc23266caf05e6 (diff)
downloadlinux-de845036f997119bcacbdb7b4ccf3b6cf960745b.tar.xz
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. Signed-off-by: Meng Tang <tangmeng@uniontech.com> Link: https://lore.kernel.org/r/20220303080206.16463-1-tangmeng@uniontech.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/berlin/berlin.c')
-rw-r--r--drivers/pinctrl/berlin/berlin.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/pinctrl/berlin/berlin.c b/drivers/pinctrl/berlin/berlin.c
index b17a03cf87be..a073eedd71aa 100644
--- a/drivers/pinctrl/berlin/berlin.c
+++ b/drivers/pinctrl/berlin/berlin.c
@@ -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++) {