pinctrl: sunxi: Fix a memory leak in 'sunxi_pinctrl_build_state()'
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Tue, 16 Oct 2018 06:22:28 +0000 (08:22 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 1 Dec 2019 08:13:25 +0000 (09:13 +0100)
commite4f1ef290e89628877088f6d2723d33e7c9090d0
tree840195715cf1616655e9e4323d5a816725795870
parentfb7a0caf45dae36dd750d596939fb805ab5b72f5
pinctrl: sunxi: Fix a memory leak in 'sunxi_pinctrl_build_state()'

[ Upstream commit a93a676b079144009f55fff2ab0e34c3b7258c8a ]

If 'krealloc()' fails, 'pctl->functions' is set to NULL.
We should instead use a temp variable in order to be able to free the
previously allocated memeory, in case of OOM.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pinctrl/sunxi/pinctrl-sunxi.c