From: Rui Miguel Silva <rmfrfs@gmail.com>
To: Chuhong Yuan <hslester96@gmail.com>
Cc: devel@driverdev.osuosl.org, Fabio Estevam <festevam@gmail.com>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
linux-kernel@vger.kernel.org, NXP Linux Team <linux-imx@nxp.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
Steve Longerbeam <slongerbeam@gmail.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Shawn Guo <shawnguo@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-media@vger.kernel.org
Subject: Re: [PATCH] media: imx7-mipi-csis: Add a check for devm_regulator_get
Date: Tue, 15 Oct 2019 09:42:16 +0100 [thread overview]
Message-ID: <m3sgnuv1qv.fsf@gmail.com> (raw)
In-Reply-To: <20191014020847.9203-1-hslester96@gmail.com>
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);
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Rui Miguel Silva <rmfrfs@gmail.com>
To: Chuhong Yuan <hslester96@gmail.com>
Cc: Steve Longerbeam <slongerbeam@gmail.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
NXP Linux Team <linux-imx@nxp.com>,
linux-media@vger.kernel.org, devel@driverdev.osuosl.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] media: imx7-mipi-csis: Add a check for devm_regulator_get
Date: Tue, 15 Oct 2019 09:42:16 +0100 [thread overview]
Message-ID: <m3sgnuv1qv.fsf@gmail.com> (raw)
In-Reply-To: <20191014020847.9203-1-hslester96@gmail.com>
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);
next prev parent reply other threads:[~2019-10-15 8:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-14 2:08 [PATCH] media: imx7-mipi-csis: Add a check for devm_regulator_get Chuhong Yuan
2019-10-14 2:08 ` Chuhong Yuan
2019-10-15 8:42 ` Rui Miguel Silva [this message]
2019-10-15 8:42 ` Rui Miguel Silva
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3sgnuv1qv.fsf@gmail.com \
--to=rmfrfs@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hslester96@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=slongerbeam@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.