regulator: s2mps11: Fix ERR_PTR dereference on GPIO lookup failure
authorKrzysztof Kozlowski <krzk@kernel.org>
Wed, 19 Jun 2019 12:42:39 +0000 (14:42 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 26 Jul 2019 07:12:56 +0000 (09:12 +0200)
commita10d287f32d1d3fd34ce6c8c3e76ee71d8327f80
treeb77c81bed28d5acf91508524766d8a1ff2590cb6
parentc4ffc082c88cb6b212f752b84f2e586d3e8ee5d3
regulator: s2mps11: Fix ERR_PTR dereference on GPIO lookup failure

commit 70ca117b02f3b1c8830fe95e4e3dea2937038e11 upstream.

If devm_gpiod_get_from_of_node() call returns ERR_PTR, it is assigned
into an array of GPIO descriptors and used later because such error is
not treated as critical thus it is not propagated back to the probe
function.

All code later expects that such GPIO descriptor is either a NULL or
proper value.  This later might lead to dereference of ERR_PTR.

Only devices with S2MPS14 flavor are affected (other do not control
regulators with GPIOs).

Fixes: 1c984942f0a4 ("regulator: s2mps11: Pass descriptor instead of GPIO number")
Cc: <stable@vger.kernel.org>
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/regulator/s2mps11.c