[PATCH 1/2] soc: imx: imx8m-blk-ctrl: Fix NULL pointer dereference

Marco Felsch m.felsch at pengutronix.de
Thu Dec 15 00:59:39 PST 2022


Hi Marek,

On 22-12-15, Marek Vasut wrote:
> Check domain->power_dev = dev_pm_domain_attach_by_name() return value using
> IS_ERR_OR_NULL() instead of plain IS_ERR(), and fail if domain->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 a few lines below in dev_set_name(domain->power_dev, ...);,
> which leads to NULL pointer dereference.

This is already fixed by b64b46fbaa1da626324f304bcb5fe0662f28b6ce.

Regards,
  Marco


> 
> Fixes: 2684ac05a8c4 ("soc: imx: add i.MX8M blk-ctrl driver")
> Signed-off-by: Marek Vasut <marex at denx.de>
> ---
> Cc: Adam Ford <aford173 at gmail.com>
> Cc: Benjamin Gaignard <benjamin.gaignard at collabora.com>
> Cc: Fabio Estevam <festevam at gmail.com>
> Cc: Lucas Stach <l.stach at pengutronix.de>
> Cc: Marco Felsch <m.felsch at pengutronix.de>
> Cc: Marek Vasut <marex at denx.de>
> Cc: NXP Linux Team <linux-imx at nxp.com>
> Cc: Paul Elder <paul.elder at ideasonboard.com>
> Cc: Peng Fan <peng.fan at nxp.com>
> Cc: Pengutronix Kernel Team <kernel at pengutronix.de>
> Cc: Sascha Hauer <s.hauer at pengutronix.de>
> Cc: Shawn Guo <shawnguo at kernel.org>
> To: linux-arm-kernel at lists.infradead.org
> ---
>  drivers/soc/imx/imx8m-blk-ctrl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/soc/imx/imx8m-blk-ctrl.c b/drivers/soc/imx/imx8m-blk-ctrl.c
> index ddcf6be3d8b4a..2fbc8e6b2644b 100644
> --- a/drivers/soc/imx/imx8m-blk-ctrl.c
> +++ b/drivers/soc/imx/imx8m-blk-ctrl.c
> @@ -256,7 +256,7 @@ static int imx8m_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);
> -- 
> 2.35.1
> 
> 



More information about the linux-arm-kernel mailing list