From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F310606A31F for ; Sun, 6 Dec 2026 07:43:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=O+I7+H9i Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C35F010E084; Sun, 6 Dec 2026 07:42:55 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6327F10E084 for ; Sun, 6 Dec 2026 07:42:49 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id A1D3F60DE1; Sun, 6 Dec 2026 07:42:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43DEB1F00A10; Sun, 6 Dec 2026 07:42:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796542968; bh=gL5prIuh8+N6ujR62Q/rG19SyMYEIWgEdZSibu7kEO4=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=O+I7+H9i3mfnK/xltQ40DiYH1hQ1inropdtPGwVjreffDPpGxd6KHxJzH9wfC/BDJ zI1LO84Gc/44jy+0kURbB7n+AMpZIUXoPZ9mj3CXgzCGR1WMVeDhRfXuvZeJI0sbvE m+3wPyZIwDY3SU4BXxIiLPNMsOy4OaFyIBq57ZxXSJNsxr0aD6HISphcHrD7hdQOY5 72EXnCzkhQRUweOzzoDDjDf+St0nOmOE3KTWuqMce3IflsaFuMgBPO+35LiH4waaDD 2D3eahE/dpRTdp1z48ytrGkAfSEL3r/ZFJ050lio9/qupRA7ZhUrQ2Irl/tRzTbZ5Y mmsbY4BQvxPLg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 4/7] accel/rocket: Serialise core probe and removal To: "Arun Iyengar" Cc: dri-devel@lists.freedesktop.org, media-ci@linuxtv.org In-Reply-To: <20261206-rocket-fixes-v4-4-75a6279bce98@gmail.com> References: <20261206-rocket-fixes-v4-0-75a6279bce98@gmail.com> <20261206-rocket-fixes-v4-4-75a6279bce98@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 06 Dec 2026 07:42:47 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] accel/rocket: devm_request_threaded_irq() outlives core slot and rdev->cores -- commit 54867f95a258b72cc2f95c965d1a7ae51bc6960f Author: Arun Iyengar accel/rocket: Serialise core probe and removal This commit serialises core probe, removal, and open under a mutex, clears core slots on removal, and picks the first free slot on probe and a bound core on open. Link: https://lore.kernel.org/all/20260922080114.44662-5-royalnet026@gmail.= com/ [1] > diff --git a/drivers/accel/rocket/rocket_drv.c b/drivers/accel/rocket/roc= ket_drv.c > index e45b3c22b31e6..ccaedb004d195 100644 > --- a/drivers/accel/rocket/rocket_drv.c > +++ b/drivers/accel/rocket/rocket_drv.c [ ... ] > @@ -246,12 +271,16 @@ static int find_core_for_dev(struct device *dev); > static void rocket_remove(struct platform_device *pdev) > { > struct device *dev =3D &pdev->dev; > - int core =3D find_core_for_dev(dev); > + int core; > + > + guard(mutex)(&rocket_cores_lock); > =20 > + core =3D find_core_for_dev(dev); > if (core < 0) > return; > =20 > rocket_core_fini(&rdev->cores[core]); > + WRITE_ONCE(rdev->cores[core].dev, NULL); > rdev->num_cores--; > =20 > if (rdev->num_cores =3D=3D 0) { [Severity: Medium] Can the shared IRQ handler registered by rocket_job_init() run after core->dev is cleared or rdev->cores is freed? rocket_job_init() registers its IRQF_SHARED handler via devm_request_threaded_irq() with core (&rdev->cores[core]) as dev_id, binding the IRQ lifetime to &pdev->dev. Neither rocket_core_fini() nor rocket_job_fini() frees the IRQ, so free_irq() only runs later in device_unbind_cleanup() -> devres_release_all() after rocket_remove() (or a failed rocket_probe()) returns and releases rocket_cores_lock: CPU0 CPU1 rocket_remove() rocket_core_fini(core) WRITE_ONCE(core->dev, NULL) /* unlocks rocket_cores_lock */ rocket_probe() /* reuses slot for new core */ rocket_job_irq_handler(..., core) <-- races with reused slot device_unbind_cleanup() devres_release_all() free_irq() In that window, rocket_job_handle_irq() also dereferences a NULL core->dev in pm_runtime_mark_last_busy(). On last-core removal, freeing rdev->cores via devres_release_group() before free_irq() runs causes a use-after-free on a shared IRQ or in __free_irq() under CONFIG_DEBUG_SHIRQ. Freeing the IRQ in rocket_job_fini() with devm_free_irq() (or switching to request_threaded_irq() and free_irq()) would ensure the handler cannot outlive the core slot. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261206-rocket-fix= es-v4-0-75a6279bce98@gmail.com?part=3D4