pinctrl: sunxi: fix 'pctrl->functions' allocation in sunxi_pinctrl_build_state
authorYueHaibing <yuehaibing@huawei.com>
Fri, 21 Sep 2018 01:59:41 +0000 (09:59 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Nov 2018 19:08:26 +0000 (11:08 -0800)
commitd2a76333ce319d79fa3128f9e16c8f4602653273
tree1c9c094189eb1ccfec1c60053b40e21bc7e17905
parent918d81fd9bfd99cabdb3ea6b47157bbeb2a5414e
pinctrl: sunxi: fix 'pctrl->functions' allocation in sunxi_pinctrl_build_state

[ Upstream commit a4925311a5443126ecc90671a1604ea7b0f5b32e ]

fixes following Smatch static check warning:

 ./drivers/pinctrl/sunxi/pinctrl-sunxi.c:1112 sunxi_pinctrl_build_state()
 warn: passing devm_ allocated variable to kfree. 'pctrl->functions'

As we will be calling krealloc() on pointer 'pctrl->functions', which means
kfree() will be called in there, devm_kzalloc() shouldn't be used with
the allocation in the first place.  Fix the warning by calling kcalloc()
and managing the free procedure in error path on our own.

Fixes: 0e37f88d9ad8 ("ARM: sunxi: Add pinctrl driver for Allwinner SoCs")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/pinctrl/sunxi/pinctrl-sunxi.c