linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: berlin: fix error return code of berlin_pinctrl_build_state()
@ 2022-03-03  8:02 Meng Tang
  2022-03-15  1:19 ` Linus Walleij
  0 siblings, 1 reply; 2+ messages in thread
From: Meng Tang @ 2022-03-03  8:02 UTC (permalink / raw)
  To: linus.walleij; +Cc: linux-gpio, linux-kernel, 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.

Signed-off-by: Meng Tang <tangmeng@uniontech.com>
---
 drivers/pinctrl/berlin/berlin.c | 2 ++
 1 file changed, 2 insertions(+)

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++) {
-- 
2.20.1




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] pinctrl: berlin: fix error return code of berlin_pinctrl_build_state()
  2022-03-03  8:02 [PATCH] pinctrl: berlin: fix error return code of berlin_pinctrl_build_state() Meng Tang
@ 2022-03-15  1:19 ` Linus Walleij
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2022-03-15  1:19 UTC (permalink / raw)
  To: Meng Tang; +Cc: linux-gpio, linux-kernel

On Thu, Mar 3, 2022 at 9:02 AM Meng Tang <tangmeng@uniontech.com> wrote:

> 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>

Patch applied!

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-15  1:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-03  8:02 [PATCH] pinctrl: berlin: fix error return code of berlin_pinctrl_build_state() Meng Tang
2022-03-15  1:19 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).