media: imx7-mipi-csis: Add a check for devm_regulator_get

devm_regulator_get may return an error but mipi_csis_phy_init misses
a check for it.
This may lead to problems when regulator_set_voltage uses the unchecked
pointer.
This patch adds a check for devm_regulator_get to avoid potential risk.

Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
Chuhong Yuan 2019-10-15 10:59:15 -03:00 committed by Mauro Carvalho Chehab
parent 61c03b631b
commit a0219deefe

View File

@ -350,6 +350,8 @@ static void mipi_csis_sw_reset(struct csi_state *state)
static int mipi_csis_phy_init(struct csi_state *state)
{
state->mipi_phy_regulator = devm_regulator_get(state->dev, "phy");
if (IS_ERR(state->mipi_phy_regulator))
return PTR_ERR(state->mipi_phy_regulator);
return regulator_set_voltage(state->mipi_phy_regulator, 1000000,
1000000);
@ -956,7 +958,10 @@ static int mipi_csis_probe(struct platform_device *pdev)
return ret;
}
mipi_csis_phy_init(state);
ret = mipi_csis_phy_init(state);
if (ret < 0)
return ret;
mipi_csis_phy_reset(state);
state->regs = devm_platform_ioremap_resource(pdev, 0);