OSDN Git Service

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)
committerLinus Walleij <linus.walleij@linaro.org>
Fri, 21 Sep 2018 16:17:27 +0000 (09:17 -0700)
commita4925311a5443126ecc90671a1604ea7b0f5b32e
tree13a760d46c326b9787df4bd9dbfa874249d5587a
parentbb8d8466ca25d6851e3e9a703d4db13c84428b43
pinctrl: sunxi: fix 'pctrl->functions' allocation in sunxi_pinctrl_build_state

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>
drivers/pinctrl/sunxi/pinctrl-sunxi.c