media: ov8865: Disable only enabled regulators on error path
authorSakari Ailus <sakari.ailus@linux.intel.com>
Wed, 15 Dec 2021 08:38:48 +0000 (09:38 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jan 2022 10:02:54 +0000 (11:02 +0100)
commit9aaf99b4a8b060028ea1d4b7ee846b96a2b2bdf9
tree3fa76ea6a399cb3133cdfd8f3a6702450f1a2b07
parenta0d6e64b3413cfe8e3839444eb45b26b9426d3c7
media: ov8865: Disable only enabled regulators on error path

commit cbe0b3af73bf72fad197756f026084404e2bcdc7 upstream.

If powering on the sensor failed, the entire power-off sequence was run
independently of how far the power-on sequence proceeded before the error.
This lead to disabling regulators and/or clock that was not enabled.

Fix this by disabling only clocks and regulators that were enabled
previously.

Fixes: 11c0d8fdccc5 ("media: i2c: Add support for the OV8865 image sensor")
Cc: stable@vger.kernel.org
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/i2c/ov8865.c