regulator: fix use after free issue
authorWen Yang <wenyang@linux.alibaba.com>
Sun, 24 Nov 2019 14:58:35 +0000 (22:58 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 12 Jan 2020 11:17:05 +0000 (12:17 +0100)
commit551d7ff754f54316ddcbc55c556bc2e20fe476f1
tree8ca1a4785948e733b6e841af6df6e5bc4b669d67
parentf70280ee8937f1e86bca940fb64b394efe74bb52
regulator: fix use after free issue

[ Upstream commit 4affd79a125ac91e6a53be843ea3960a8fc00cbb ]

This is caused by dereferencing 'rdev' after put_device() in
the _regulator_get()/_regulator_put() functions.
This patch just moves the put_device() down a bit to avoid the
issue.

Signed-off-by: Wen Yang <wenyang@linux.alibaba.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: linux-kernel@vger.kernel.org
Link: https://lore.kernel.org/r/20191124145835.25999-1-wenyang@linux.alibaba.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/regulator/core.c