Commit d9e47351 authored by Marek Vasut's avatar Marek Vasut Committed by Ulf Hansson

pmdomain: imx8mp-blk-ctrl: Error out if domains are missing in DT

This driver assumes that domain->power_dev is non-NULL in its
suspend/resume path. The assumption is valid, since all the devices that
are being looked up here should be described in DT. In case they are not
described in DT, because the DT is faulty, suspend/resume attempt would
trigger NULL pointer dereference.

To avoid this failure, check whether the power_dev assignment is not NULL
right away in probe callback and fail early if it is.
Signed-off-by: default avatarMarek Vasut <marex@denx.de>
Reviewed-by: default avatarPeng Fan <peng.fan@nxp.com>
Link: https://lore.kernel.org/r/20240119014807.268694-1-marex@denx.deSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 5d7f58ee
......@@ -258,11 +258,14 @@ 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)) {
dev_err_probe(dev, PTR_ERR(domain->power_dev),
if (IS_ERR_OR_NULL(domain->power_dev)) {
if (!domain->power_dev)
ret = -ENODEV;
else
ret = PTR_ERR(domain->power_dev);
dev_err_probe(dev, ret,
"failed to attach power domain \"%s\"\n",
data->gpc_name);
ret = PTR_ERR(domain->power_dev);
goto cleanup_pds;
}
......
......@@ -687,11 +687,14 @@ 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)) {
dev_err_probe(dev, PTR_ERR(domain->power_dev),
if (IS_ERR_OR_NULL(domain->power_dev)) {
if (!domain->power_dev)
ret = -ENODEV;
else
ret = PTR_ERR(domain->power_dev);
dev_err_probe(dev, ret,
"failed to attach power domain %s\n",
data->gpc_name);
ret = PTR_ERR(domain->power_dev);
goto cleanup_pds;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment