mirror of
https://github.com/torvalds/linux.git
synced 2024-11-25 13:41:51 +00:00
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: Marek Vasut <marex@denx.de> Reviewed-by: Peng Fan <peng.fan@nxp.com> Link: https://lore.kernel.org/r/20240119014807.268694-1-marex@denx.de Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
parent
5d7f58ee08
commit
d9e4735139
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user