Skip to content

Commit d9e4735

Browse files
Marek Vasutstorulf
authored andcommitted
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>
1 parent 5d7f58e commit d9e4735

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

drivers/pmdomain/imx/imx8m-blk-ctrl.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,14 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
258258

259259
domain->power_dev =
260260
dev_pm_domain_attach_by_name(dev, data->gpc_name);
261-
if (IS_ERR(domain->power_dev)) {
262-
dev_err_probe(dev, PTR_ERR(domain->power_dev),
261+
if (IS_ERR_OR_NULL(domain->power_dev)) {
262+
if (!domain->power_dev)
263+
ret = -ENODEV;
264+
else
265+
ret = PTR_ERR(domain->power_dev);
266+
dev_err_probe(dev, ret,
263267
"failed to attach power domain \"%s\"\n",
264268
data->gpc_name);
265-
ret = PTR_ERR(domain->power_dev);
266269
goto cleanup_pds;
267270
}
268271

drivers/pmdomain/imx/imx8mp-blk-ctrl.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,11 +687,14 @@ static int imx8mp_blk_ctrl_probe(struct platform_device *pdev)
687687

688688
domain->power_dev =
689689
dev_pm_domain_attach_by_name(dev, data->gpc_name);
690-
if (IS_ERR(domain->power_dev)) {
691-
dev_err_probe(dev, PTR_ERR(domain->power_dev),
690+
if (IS_ERR_OR_NULL(domain->power_dev)) {
691+
if (!domain->power_dev)
692+
ret = -ENODEV;
693+
else
694+
ret = PTR_ERR(domain->power_dev);
695+
dev_err_probe(dev, ret,
692696
"failed to attach power domain %s\n",
693697
data->gpc_name);
694-
ret = PTR_ERR(domain->power_dev);
695698
goto cleanup_pds;
696699
}
697700

0 commit comments

Comments
 (0)