All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] media: imx7-mipi-csis: Add a check for devm_regulator_get
@ 2019-10-15 13:59 ` Chuhong Yuan
  0 siblings, 0 replies; 18+ messages in thread
From: Chuhong Yuan @ 2019-10-15 13:59 UTC (permalink / raw)
  Cc: Rui Miguel Silva, Steve Longerbeam, Philipp Zabel,
	Mauro Carvalho Chehab, Greg Kroah-Hartman, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, linux-media, devel, linux-arm-kernel,
	linux-kernel, Chuhong Yuan

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>
---
Changes in v2:
  - Add a check in mipi_csis_probe for the modified mipi_csis_phy_init.

 drivers/staging/media/imx/imx7-mipi-csis.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c
index 73d8354e618c..e8a6acaa969e 100644
--- a/drivers/staging/media/imx/imx7-mipi-csis.c
+++ b/drivers/staging/media/imx/imx7-mipi-csis.c
@@ -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);
@@ -966,7 +968,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);
 
 	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2019-10-17  9:46 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-15 13:59 [PATCH v2] media: imx7-mipi-csis: Add a check for devm_regulator_get Chuhong Yuan
2019-10-15 13:59 ` Chuhong Yuan
2019-10-15 13:59 ` Chuhong Yuan
2019-10-16  9:06 ` Marco Felsch
2019-10-16  9:06   ` Marco Felsch
2019-10-16  9:06   ` Marco Felsch
2019-10-16 13:43   ` Rui Miguel Silva
2019-10-16 13:43     ` Rui Miguel Silva
2019-10-16 13:43     ` Rui Miguel Silva
2019-10-17  8:10     ` Marco Felsch
2019-10-17  8:10       ` Marco Felsch
2019-10-17  8:10       ` Marco Felsch
2019-10-17  9:43       ` Rui Miguel Silva
2019-10-17  9:43         ` Rui Miguel Silva
2019-10-17  9:43         ` Rui Miguel Silva
2019-10-17  9:46 ` Rui Miguel Silva
2019-10-17  9:46   ` Rui Miguel Silva
2019-10-17  9:46   ` Rui Miguel Silva

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.