]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
pinctrl: berlin: fix 'pctrl->functions' allocation in berlin_pinctrl_build_state
authorYueHaibing <yuehaibing@huawei.com>
Wed, 1 Aug 2018 05:10:49 +0000 (13:10 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Sep 2018 20:41:24 +0000 (22:41 +0200)
commit9a5cbf5c84a141fdcf1db24424fa18273058790e
treebcc07688c901acd5ca268357c9be251d6673a815
parent074f319a5c13a2b2db1c44d95a2b8afddf7cee6e
pinctrl: berlin: fix 'pctrl->functions' allocation in berlin_pinctrl_build_state

[ Upstream commit b5031b7db77dc47f474f0efc2b2552c32b7bb59d ]

fixes following Smatch static check warning:

 drivers/pinctrl/berlin/berlin.c:237 berlin_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: 3de68d331c24 ("pinctrl: berlin: add the core pinctrl driver for Marvell Berlin SoCs")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Reviewed-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/pinctrl/berlin/berlin.c