Re: [PATCH] soc: imx: imx8m-blk-ctrl: Fix NULL pointer dereference
From: Marco Felsch
Date: Thu Aug 08 2024 - 02:14:35 EST
Hi Ma,
On 24-08-08, Ma Ke wrote:
> Check bc->bus_power_dev = dev_pm_domain_attach_by_name() return value using
> IS_ERR_OR_NULL() instead of plain IS_ERR(), and fail if bc->bus_power_dev
> is either error or NULL.
>
> In case a power domain attached by dev_pm_domain_attach_by_name() is not
> described in DT, dev_pm_domain_attach_by_name() returns NULL, which is
> then used, which leads to NULL pointer dereference.
the same comment I wrote previously applies to this patch.
Regards,
Marco
>
> Found by code review.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: 1a1da28544fd ("soc: imx: imx8m-blk-ctrl: Defer probe if 'bus' genpd is not yet ready")
> Signed-off-by: Ma Ke <make24@xxxxxxxxxxx>
> ---
> drivers/pmdomain/imx/imx8m-blk-ctrl.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pmdomain/imx/imx8m-blk-ctrl.c b/drivers/pmdomain/imx/imx8m-blk-ctrl.c
> index ca942d7929c2..d46fb5387148 100644
> --- a/drivers/pmdomain/imx/imx8m-blk-ctrl.c
> +++ b/drivers/pmdomain/imx/imx8m-blk-ctrl.c
> @@ -212,7 +212,7 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> bc->bus_power_dev = dev_pm_domain_attach_by_name(dev, "bus");
> - if (IS_ERR(bc->bus_power_dev)) {
> + if (IS_ERR_OR_NULL(bc->bus_power_dev)) {
> if (PTR_ERR(bc->bus_power_dev) == -ENODEV)
> return dev_err_probe(dev, -EPROBE_DEFER,
> "failed to attach power domain \"bus\"\n");
> --
> 2.25.1
>
>
>