From nobody Sun Feb 8 02:34:49 2026 Received: from smtp-1909.mail.infomaniak.ch (smtp-1909.mail.infomaniak.ch [185.125.25.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBF4B2BD02A for ; Mon, 15 Dec 2025 16:45:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.25.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765817112; cv=none; b=Ci7LcwYDsrBsiQR8jHKrdhGjpcNecCf/j5mRxJ7wDPzPhLRWA1OY3ZqGiRBM/cyVISxDYP16Ti6786E9QQroOBMwPp/9/U+0HK5WU/zPyLNPcO798nCNaYKQKlWyGE+fhmOEBJVjD1LJ0YiDYvzqg6NSUsu/IkMw0fDxLLSc8EU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765817112; c=relaxed/simple; bh=0RY55mfFGBRtNJiEK3rjYCjDswnCcRH35/VFzL8Oigk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UaHZjZaKRO3zs5PlzE+0DRZcyantjaAurA1kZTbxeYOH71oqqZKGpTy+6Skun6YJCY+AbfHkczeqKkBij8tDYwStTaBwpSNjHBZxnlFQI0wCJeWzsPvel4YBCykUzjix7Xh97YTrT3kfe2rdwpleGlv7j0eTB3u/5d8p7yTshKc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0leil.net; spf=pass smtp.mailfrom=0leil.net; arc=none smtp.client-ip=185.125.25.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0leil.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=0leil.net Received: from smtp-4-0000.mail.infomaniak.ch (smtp-4-0000.mail.infomaniak.ch [10.7.10.107]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4dVQgQ4pTnz6Cy; Mon, 15 Dec 2025 17:36:34 +0100 (CET) Received: from unknown by smtp-4-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4dVQgQ0R3wzCMS; Mon, 15 Dec 2025 17:36:34 +0100 (CET) From: Quentin Schulz Date: Mon, 15 Dec 2025 17:36:14 +0100 Subject: [PATCH 1/2] accel/rocket: fix unwinding in error path in rocket_core_init Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251215-rocket-error-path-v1-1-eec3bf29dc3b@cherry.de> References: <20251215-rocket-error-path-v1-0-eec3bf29dc3b@cherry.de> In-Reply-To: <20251215-rocket-error-path-v1-0-eec3bf29dc3b@cherry.de> To: Tomeu Vizoso , Oded Gabbay , Jeff Hugo Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Quentin Schulz , stable@vger.kernel.org X-Mailer: b4 0.14.3 X-Infomaniak-Routing: alpha From: Quentin Schulz 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: 0810d5ad88a1 ("accel/rocket: Add job submission IOCTL") Cc: stable@vger.kernel.org Signed-off-by: Quentin Schulz --- drivers/accel/rocket/rocket_core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/accel/rocket/rocket_core.c b/drivers/accel/rocket/rock= et_core.c index abe7719c1db46..b3b2fa9ba645a 100644 --- a/drivers/accel/rocket/rocket_core.c +++ b/drivers/accel/rocket/rocket_core.c @@ -59,8 +59,11 @@ int rocket_core_init(struct rocket_core *core) core->iommu_group =3D iommu_group_get(dev); =20 err =3D rocket_job_init(core); - if (err) + if (err) { + iommu_group_put(core->iommu_group); + core->iommu_group =3D NULL; return err; + } =20 pm_runtime_use_autosuspend(dev); =20 @@ -76,7 +79,7 @@ int rocket_core_init(struct rocket_core *core) =20 err =3D pm_runtime_resume_and_get(dev); if (err) { - rocket_job_fini(core); + rocket_core_fini(core); return err; } =20 --=20 2.52.0 From nobody Sun Feb 8 02:34:49 2026 Received: from smtp-190b.mail.infomaniak.ch (smtp-190b.mail.infomaniak.ch [185.125.25.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E752C33711E for ; Mon, 15 Dec 2025 16:55:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.25.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765817712; cv=none; b=cUkYxMUBIJSGNkz+ZiD218Zo6sBTA8RApsbWLuSnwNjMIjAj/uF7gtSFwptHa8V5hnL+ruomALbGqWFRtH1JgNBJw8gDEQIq/rv6VPcH+DV/L6z5HE9qxWr6iSIBcWKlkiP77C3h05lFszdB9pcC6L7A/LWI5heGByTQunkCnck= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765817712; c=relaxed/simple; bh=0Yi8JEKuzVcbsTEPlH3Bby1aFOoivGjQc0Z4blrnl4Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=An+SR0AxDt5UWxTe6Y1Ko8VhMjkwo2OJoYG2hIdDzrde0cZFXs1sETzR+Pd33HZgTz7Qm3BJjxvaZvYwMIRLE32yblWJeTXCiTYdkpl2iYec4sBLhU4xxr4J3wrqzc19mu+8RhRJOqcC2RQZ5Wtk2aG8scRfPSqqZQQyWVgdBgQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0leil.net; spf=pass smtp.mailfrom=0leil.net; arc=none smtp.client-ip=185.125.25.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0leil.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=0leil.net Received: from smtp-4-0000.mail.infomaniak.ch (smtp-4-0000.mail.infomaniak.ch [10.7.10.107]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4dVQgR2whbz6Mb; Mon, 15 Dec 2025 17:36:35 +0100 (CET) Received: from unknown by smtp-4-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4dVQgQ5X8Nz9pt; Mon, 15 Dec 2025 17:36:34 +0100 (CET) From: Quentin Schulz Date: Mon, 15 Dec 2025 17:36:15 +0100 Subject: [PATCH 2/2] accel/rocket: fix unwinding in error path in rocket_probe Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251215-rocket-error-path-v1-2-eec3bf29dc3b@cherry.de> References: <20251215-rocket-error-path-v1-0-eec3bf29dc3b@cherry.de> In-Reply-To: <20251215-rocket-error-path-v1-0-eec3bf29dc3b@cherry.de> To: Tomeu Vizoso , Oded Gabbay , Jeff Hugo Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Quentin Schulz , stable@vger.kernel.org X-Mailer: b4 0.14.3 X-Infomaniak-Routing: alpha From: Quentin Schulz When rocket_core_init() fails (as could be the case with EPROBE_DEFER), we need to properly unwind by decrementing the counter we just incremented and if this is the first core we failed to probe, remove the rocket DRM device with rocket_device_fini() as well. This matches the logic in rocket_remove(). Failing to properly unwind results in out-of-bounds accesses. Fixes: 0810d5ad88a1 ("accel/rocket: Add job submission IOCTL") Cc: stable@vger.kernel.org Signed-off-by: Quentin Schulz --- Note that this means that, technically, the first core (in HW) may not be the first core in the kernel (if EPROBE_DEFER is returned by the first core's probe for example). This may be a real issue if we rely on this. E.g. I see the iommu domain is set in in rocket_open() with rocket_iommu_domain_create(rdev->cores[0].dev) which could be expecting the main core (but it isn't clear from the commit logs, so maybe all cores may be totally independent). In any case, this patch is keeping the status quo. --- drivers/accel/rocket/rocket_drv.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/accel/rocket/rocket_drv.c b/drivers/accel/rocket/rocke= t_drv.c index 5c0b63f0a8f00..f6ef4c7aeef11 100644 --- a/drivers/accel/rocket/rocket_drv.c +++ b/drivers/accel/rocket/rocket_drv.c @@ -13,6 +13,7 @@ #include #include =20 +#include "rocket_device.h" #include "rocket_drv.h" #include "rocket_gem.h" #include "rocket_job.h" @@ -158,6 +159,8 @@ static const struct drm_driver rocket_drm_driver =3D { =20 static int rocket_probe(struct platform_device *pdev) { + int ret; + if (rdev =3D=3D NULL) { /* First core probing, initialize DRM device. */ rdev =3D rocket_device_init(drm_dev, &rocket_drm_driver); @@ -177,7 +180,17 @@ static int rocket_probe(struct platform_device *pdev) =20 rdev->num_cores++; =20 - return rocket_core_init(&rdev->cores[core]); + ret =3D rocket_core_init(&rdev->cores[core]); + if (ret) { + rdev->num_cores--; + + if (rdev->num_cores =3D=3D 0) { + rocket_device_fini(rdev); + rdev =3D NULL; + } + } + + return ret; } =20 static void rocket_remove(struct platform_device *pdev) --=20 2.52.0