memory: samsung: exynos5422-dmc: Avoid some over memory allocation
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 20 Mar 2022 07:10:30 +0000 (08:10 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:23:04 +0000 (10:23 +0200)
commitcd1d22174175ba1b5921c465199f64aa8bb1b8db
treeaa6792a903c8c124722f1d81adaa8d60d6fe3c1a
parent4cb6687016b4d0237aa89d4b6cb7580e80c42db9
memory: samsung: exynos5422-dmc: Avoid some over memory allocation

[ Upstream commit 56653827f0d7bc7c2d8bac0e119fd1521fa9990a ]

'dmc->counter' is a 'struct devfreq_event_dev **', so there is some
over memory allocation. 'counters_size' should be computed with
'sizeof(struct devfreq_event_dev *)'.

Use 'sizeof(*dmc->counter)' instead to fix it.

While at it, use devm_kcalloc() instead of devm_kzalloc()+open coded
multiplication.

Fixes: 6e7674c3c6df ("memory: Add DMC driver for Exynos5422")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/69d7e69346986e2fdb994d4382954c932f9f0993.1647760213.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/memory/samsung/exynos5422-dmc.c