remoteproc: imx_rproc: Fix refcount mistake in imx_rproc_addr_init

[ Upstream commit dce68a49be26abf52712e0ee452a45fa01ab4624 ]

In imx_rproc_addr_init() strcmp() is performed over the node after the
of_node_put() is performed over it.
Fix this error by moving of_node_put() calls.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 5e4c124307 ("remoteproc: imx_rproc: support remote cores booted before Linux Kernel")
Cc: stable@vger.kernel.org
Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
Link: https://lore.kernel.org/r/20240612131714.12907-1-amishin@t-argos.ru
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Aleksandr Mishin 2024-06-12 16:17:14 +03:00 коммит произвёл Greg Kroah-Hartman
Родитель 39b3e0b18f
Коммит 380fa8172e
1 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -596,25 +596,29 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
continue; continue;
} }
err = of_address_to_resource(node, 0, &res); err = of_address_to_resource(node, 0, &res);
of_node_put(node);
if (err) { if (err) {
dev_err(dev, "unable to resolve memory region\n"); dev_err(dev, "unable to resolve memory region\n");
of_node_put(node);
return err; return err;
} }
if (b >= IMX_RPROC_MEM_MAX) if (b >= IMX_RPROC_MEM_MAX) {
of_node_put(node);
break; break;
}
/* Not use resource version, because we might share region */ /* Not use resource version, because we might share region */
priv->mem[b].cpu_addr = devm_ioremap(&pdev->dev, res.start, resource_size(&res)); priv->mem[b].cpu_addr = devm_ioremap(&pdev->dev, res.start, resource_size(&res));
if (!priv->mem[b].cpu_addr) { if (!priv->mem[b].cpu_addr) {
dev_err(dev, "failed to remap %pr\n", &res); dev_err(dev, "failed to remap %pr\n", &res);
of_node_put(node);
return -ENOMEM; return -ENOMEM;
} }
priv->mem[b].sys_addr = res.start; priv->mem[b].sys_addr = res.start;
priv->mem[b].size = resource_size(&res); priv->mem[b].size = resource_size(&res);
if (!strcmp(node->name, "rsc-table")) if (!strcmp(node->name, "rsc-table"))
priv->rsc_table = priv->mem[b].cpu_addr; priv->rsc_table = priv->mem[b].cpu_addr;
of_node_put(node);
b++; b++;
} }