* [PATCH] media: imx7-mipi-csis: Add a check for devm_regulator_get
@ 2019-10-14 2:08 Chuhong Yuan
2019-10-15 8:42 ` Rui Miguel Silva
0 siblings, 1 reply; 2+ messages in thread
From: Chuhong Yuan @ 2019-10-14 2:08 UTC (permalink / raw)
Cc: devel, Pengutronix Kernel Team, Greg Kroah-Hartman, Sascha Hauer,
Chuhong Yuan, linux-kernel, NXP Linux Team, Philipp Zabel,
Steve Longerbeam, Mauro Carvalho Chehab, Shawn Guo,
linux-arm-kernel, linux-media
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>
---
drivers/staging/media/imx/imx7-mipi-csis.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c
index 73d8354e618c..9a07b54c4ab1 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);
--
2.20.1
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] media: imx7-mipi-csis: Add a check for devm_regulator_get
2019-10-14 2:08 [PATCH] media: imx7-mipi-csis: Add a check for devm_regulator_get Chuhong Yuan
@ 2019-10-15 8:42 ` Rui Miguel Silva
0 siblings, 0 replies; 2+ messages in thread
From: Rui Miguel Silva @ 2019-10-15 8:42 UTC (permalink / raw)
To: Chuhong Yuan
Cc: devel, Pengutronix Kernel Team, Greg Kroah-Hartman, Sascha Hauer,
linux-kernel, NXP Linux Team, Philipp Zabel, Steve Longerbeam,
Mauro Carvalho Chehab, Shawn Guo, linux-arm-kernel, linux-media
Hi Chuhong,
Thanks for the patch.
On Mon 14 Oct 2019 at 03:08, Chuhong Yuan wrote:
> 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>
> ---
> drivers/staging/media/imx/imx7-mipi-csis.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c
> index 73d8354e618c..9a07b54c4ab1 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);
This regulator is marked as mandatory in the device tree entry,
however it looks good to me to have this check, even because it
can return -EPROBE_DEFER and we need to retry.
But for that we may need to extend this patch to make the caller
of this (mipi_csis_probe), to also really care about the returned
code.
Cheers,
Rui
>
> return regulator_set_voltage(state->mipi_phy_regulator, 1000000,
> 1000000);
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-10-15 8:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-14 2:08 [PATCH] media: imx7-mipi-csis: Add a check for devm_regulator_get Chuhong Yuan
2019-10-15 8:42 ` Rui Miguel Silva
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).