All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Tang Bin <tangbin@cmss.chinamobile.com>
Cc: shawnguo@kernel.org, s.hauer@pengutronix.de,
	kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] soc: imx: fix error check in imx8mp_blk_ctrl_probe()
Date: Tue, 13 Sep 2022 08:39:30 +0100	[thread overview]
Message-ID: <YyAzsl72LzMTdoDF@shell.armlinux.org.uk> (raw)
In-Reply-To: <20220913073434.7252-1-tangbin@cmss.chinamobile.com>

On Tue, Sep 13, 2022 at 03:34:34PM +0800, Tang Bin wrote:
> In the function imx8mp_blk_ctrl_probe(),
> dev_pm_domain_attach_by_name() may return NULL in some cases,
> so IS_ERR() doesn't meet the requirements. Thus fix it.
> 
> Fixes: 556f5cf9568a ("soc: imx: add i.MX8MP HSIO blk-ctrl")
> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
> ---
>  drivers/soc/imx/imx8mp-blk-ctrl.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/soc/imx/imx8mp-blk-ctrl.c b/drivers/soc/imx/imx8mp-blk-ctrl.c
> index ccb30c6cd..ed8557eaf 100644
> --- a/drivers/soc/imx/imx8mp-blk-ctrl.c
> +++ b/drivers/soc/imx/imx8mp-blk-ctrl.c
> @@ -597,11 +597,11 @@ static int imx8mp_blk_ctrl_probe(struct platform_device *pdev)
>  
>  		domain->power_dev =
>  			dev_pm_domain_attach_by_name(dev, data->gpc_name);
> -		if (IS_ERR(domain->power_dev)) {
> +		if (IS_ERR_OR_NULL(domain->power_dev)) {
>  			dev_err_probe(dev, PTR_ERR(domain->power_dev),
>  				      "failed to attach power domain %s\n",
>  				      data->gpc_name);
> -			ret = PTR_ERR(domain->power_dev);
> +			ret = PTR_ERR(domain->power_dev) ? : -ENODATA;
>  			goto cleanup_pds;
>  		}
>  		dev_set_name(domain->power_dev, "%s", data->name);

Checking for NULL in this case is likely a good idea, as if
domain->power_dev is NULL, then dev_set_name() will probably oops the
kernel. Whether returning -ENODATA and causing a failure, or whether
moving on to the next domain is a question that the maintainers of
this code need to answer, bearing in mind that NULL here means that
the device doesn't need a power domain.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
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: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Tang Bin <tangbin@cmss.chinamobile.com>
Cc: shawnguo@kernel.org, s.hauer@pengutronix.de,
	kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] soc: imx: fix error check in imx8mp_blk_ctrl_probe()
Date: Tue, 13 Sep 2022 08:39:30 +0100	[thread overview]
Message-ID: <YyAzsl72LzMTdoDF@shell.armlinux.org.uk> (raw)
In-Reply-To: <20220913073434.7252-1-tangbin@cmss.chinamobile.com>

On Tue, Sep 13, 2022 at 03:34:34PM +0800, Tang Bin wrote:
> In the function imx8mp_blk_ctrl_probe(),
> dev_pm_domain_attach_by_name() may return NULL in some cases,
> so IS_ERR() doesn't meet the requirements. Thus fix it.
> 
> Fixes: 556f5cf9568a ("soc: imx: add i.MX8MP HSIO blk-ctrl")
> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
> ---
>  drivers/soc/imx/imx8mp-blk-ctrl.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/soc/imx/imx8mp-blk-ctrl.c b/drivers/soc/imx/imx8mp-blk-ctrl.c
> index ccb30c6cd..ed8557eaf 100644
> --- a/drivers/soc/imx/imx8mp-blk-ctrl.c
> +++ b/drivers/soc/imx/imx8mp-blk-ctrl.c
> @@ -597,11 +597,11 @@ static int imx8mp_blk_ctrl_probe(struct platform_device *pdev)
>  
>  		domain->power_dev =
>  			dev_pm_domain_attach_by_name(dev, data->gpc_name);
> -		if (IS_ERR(domain->power_dev)) {
> +		if (IS_ERR_OR_NULL(domain->power_dev)) {
>  			dev_err_probe(dev, PTR_ERR(domain->power_dev),
>  				      "failed to attach power domain %s\n",
>  				      data->gpc_name);
> -			ret = PTR_ERR(domain->power_dev);
> +			ret = PTR_ERR(domain->power_dev) ? : -ENODATA;
>  			goto cleanup_pds;
>  		}
>  		dev_set_name(domain->power_dev, "%s", data->name);

Checking for NULL in this case is likely a good idea, as if
domain->power_dev is NULL, then dev_set_name() will probably oops the
kernel. Whether returning -ENODATA and causing a failure, or whether
moving on to the next domain is a question that the maintainers of
this code need to answer, bearing in mind that NULL here means that
the device doesn't need a power domain.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

  reply	other threads:[~2022-09-13  7:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-13  7:34 [PATCH] soc: imx: fix error check in imx8mp_blk_ctrl_probe() Tang Bin
2022-09-13  7:34 ` Tang Bin
2022-09-13  7:39 ` Russell King (Oracle) [this message]
2022-09-13  7:39   ` Russell King (Oracle)

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=YyAzsl72LzMTdoDF@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=festevam@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=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=tangbin@cmss.chinamobile.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.