]> git.itanic.dy.fi Git - linux-stable/commit
regulator: pfuze100: Fix the global-out-of-bounds access in pfuze100_regulator_probe()
authorXiaolei Wang <xiaolei.wang@windriver.com>
Thu, 25 Aug 2022 11:19:22 +0000 (19:19 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Sep 2022 09:02:52 +0000 (11:02 +0200)
commit4863a2db387a3ae1a79de33febe0807f2a0b87f7
tree1e8d370f084249b71c63143cba18a231a86feb18
parente771465b5001097520707a2c49ce68cc8d951c5c
regulator: pfuze100: Fix the global-out-of-bounds access in pfuze100_regulator_probe()

[ Upstream commit 78e1e867f44e6bdc72c0e6a2609a3407642fb30b ]

The pfuze_chip::regulator_descs is an array of size
PFUZE100_MAX_REGULATOR, the pfuze_chip::pfuze_regulators
is the pointer to the real regulators of a specific device.
The number of real regulator is supposed to be less than
the PFUZE100_MAX_REGULATOR, so we should use the size of
'regulator_num * sizeof(struct pfuze_regulator)' in memcpy().
This fixes the out of bounds access bug reported by KASAN.

Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
Link: https://lore.kernel.org/r/20220825111922.1368055-1-xiaolei.wang@windriver.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/regulator/pfuze100-regulator.c