From: Meng Tang Date: Thu, 3 Mar 2022 08:02:06 +0000 (+0800) Subject: pinctrl: berlin: fix error return code of berlin_pinctrl_build_state() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=de845036f997119bcacbdb7b4ccf3b6cf960745b;p=linux.git 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 Link: https://lore.kernel.org/r/20220303080206.16463-1-tangmeng@uniontech.com Signed-off-by: Linus Walleij --- diff --git a/drivers/pinctrl/berlin/berlin.c b/drivers/pinctrl/berlin/berlin.c index b17a03cf87bea..a073eedd71aa5 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++) {