Skip to content

Commit 08b41f3

Browse files
QSchulzSasha Levin
authored andcommitted
accel/rocket: fix unwinding in error path in rocket_core_init
[ Upstream commit f509a08 ] When rocket_job_init() is called, iommu_group_get() has already been called, therefore we should call iommu_group_put() and make the iommu_group pointer NULL. This aligns with what's done in rocket_core_fini(). If pm_runtime_resume_and_get() somehow fails, not only should rocket_job_fini() be called but we should also unwind everything done before that, that is, disable PM, put the iommu_group, NULLify it and then call rocket_job_fini(). This is exactly what's done in rocket_core_fini() so let's call that function instead of duplicating the code. Fixes: 0810d5a ("accel/rocket: Add job submission IOCTL") Cc: stable@vger.kernel.org Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de> Reviewed-by: Tomeu Vizoso <tomeu@tomeuvizoso.net> Signed-off-by: Tomeu Vizoso <tomeu@tomeuvizoso.net> Link: https://patch.msgid.link/20251215-rocket-error-path-v1-1-eec3bf29dc3b@cherry.de Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 188338c commit 08b41f3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/accel/rocket/rocket_core.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ int rocket_core_init(struct rocket_core *core)
5959
core->iommu_group = iommu_group_get(dev);
6060

6161
err = rocket_job_init(core);
62-
if (err)
62+
if (err) {
63+
iommu_group_put(core->iommu_group);
64+
core->iommu_group = NULL;
6365
return err;
66+
}
6467

6568
pm_runtime_use_autosuspend(dev);
6669

@@ -76,7 +79,7 @@ int rocket_core_init(struct rocket_core *core)
7679

7780
err = pm_runtime_resume_and_get(dev);
7881
if (err) {
79-
rocket_job_fini(core);
82+
rocket_core_fini(core);
8083
return err;
8184
}
8285

0 commit comments

Comments
 (0)