From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796292085; b=LfiMsSk+VRZYermMhtvEn8VWU49C1Mt8Xdpi7h9hYWDTV96B6b/VXOZQ9Bl+zGo+0GB/ gZ5FEon/z7zRaUpYjwmoRmh/FiqXLU0CfUiNFX+xA5Zdx3KoqHt+qwOu/OnAWo1QWvqMe YxrRWHrdipaG3rtDNv+17Oqu7nSUoInSKwofAyTeVD8DRpoLeuKALJmSviOKRH9F3cNRk 6yt5Am2J9L0ajDHc47+T9/dM6pQW9iucZhFf8v/PKaS4oBXMZowPe5o5YQfufYwI4N+Yq 2M34ZCEE5/65Lb1HI1O1xG36CXd2pDUorNWIgNLCN3Bbk8onrfx+H85SXtLBhNB+5rg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796292085; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=eedqrfpL8x/+U1tfGwUINXwvnuTWCm+/k398rdERz4w=; b=5DI8SUtNNsIgRWa8h43mEtm3sYRwAUxySaeZEyDilgtifgl/JMYgW8nDi99DepZ9zoWn vQ/nLfZi2LO4p4s7EWrxzWtsAhJRmjUnl44VvKn6vbkmg2s+8cE48oI/z4EE8aWnufIZl 4B2cdUyPqsboAxPCuTSfG1YQyP4uSRy3FItFEku0go45kbr3YUVijSQQXC4yMLlwzE6n+ XZG+9vccycbxIlxuSvOANml3X3Gfc4pZxs9B0ZmzJlzzdlkd0DvVgP+EFeVdhwVlt5e7a AuYtgiyMHrFdo/FzhyIlr0nziCR8N5/A9xu0ASKfpMUDV8LamiFPbcDInKm6297u5eA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=H0VLrqVQ; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01B80606A322 for ; Thu, 3 Dec 2026 10:01:24 +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=H0VLrqVQ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76CBD1F00893; Thu, 3 Dec 2026 10:01:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796292084; bh=eedqrfpL8x/+U1tfGwUINXwvnuTWCm+/k398rdERz4w=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=H0VLrqVQUh/k1O8U+6QY5qcxaAn4WPP+lTg2ZyZmVA0UI5JipARE866f6aI4u235k ZxBQKpGXrJ3gAQO8irb08LGEa6cKVkjNJf2LI4pQw3r/SpjILoTN3CigllQbneG8gL AWcBq625h6xB1VnXu0WyEHG//k+6TPVmh6hyY+etkvzRfYo6guPaIgKhX13tgx9Pat L/paXrKW/I1P3m+1tvAx5ZMxvJt5078lXPD1TKjWiWa/bQ1TxaEhwkm9/YUktzRIoj X8u+VDqpuSBTing8ge7ljdGbNrduzl3wz7r7ahplT7TvqZSxj1brvopeZ+516zirEo JxUlD0QNucizw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 8/8] irqchip/imx-intmux: Factor out imx_intmux_teardown_channel() Reply-To: sashiko-reviews@lists.linux.dev To: "Peng Fan" Cc: imx@lists.linux.dev, Frank.Li@kernel.org In-Reply-To: <20261203-imx-intmux-v2-8-a6db1eed3b5f@nxp.com> References: <20261203-imx-intmux-v2-0-a6db1eed3b5f@nxp.com> <20261203-imx-intmux-v2-8-a6db1eed3b5f@nxp.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 10:01:24 +0000 X-Mailing-List: imx@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] irqchip/imx-intmux: lazy disable_irq() races with handler teardown -- commit 58ddadbb56d0e9d72dc72cc109e6fc29fd9722be Author: Peng Fan irqchip/imx-intmux: Factor out imx_intmux_teardown_channel() This commit factors the per-channel teardown sequence out of the probe error path and imx_intmux_remove() into imx_intmux_teardown_channel(). > diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-i= ntmux.c > index eeba45f312be9..cce21ac8c21d5 100644 > --- a/drivers/irqchip/irq-imx-intmux.c > +++ b/drivers/irqchip/irq-imx-intmux.c > @@ -200,6 +200,21 @@ static void imx_intmux_irq_handler(struct irq_desc *= desc) > generic_handle_domain_irq(irqchip_data->domain, pos); > } > =20 > +static void imx_intmux_teardown_channel(struct intmux_data *data, int i) > +{ > + /* > + * Mask the parent interrupt and wait for a handler that is already > + * running to finish before its handler data, chip and mappings are > + * torn down. irq_dispose_mapping() installs no_irq_chip before its > + * own synchronize_irq(), which loses the GIC active-state check. > + */ > + disable_irq(data->irqchip_data[i].irq); > + irq_set_chained_handler_and_data(data->irqchip_data[i].irq, NULL, NULL); > + for (unsigned int hwirq =3D 0; hwirq < 32; hwirq++) > + irq_dispose_mapping(irq_find_mapping(data->irqchip_data[i].domain, hwi= rq)); > + irq_dispose_mapping(data->irqchip_data[i].irq); > +} > + [Severity: Medium] Can disable_irq() leave the parent GIC SPI unmasked in hardware and let imx_intmux_irq_handler() race with irq_set_chained_handler_and_data()? On GICv3, neither gic_chip nor gic_eoimode1_chip implements .irq_disable, and IRQ_DISABLE_UNLAZY is not set on the parent SPI. disable_irq() therefore calls __irq_disable(desc, false), which only sets IRQD_IRQ_DISABLED in software and skips mask_irq(). Unlike standard flow handlers, imx_intmux_irq_handler() runs without checking irqd_irq_disabled() or setting IRQD_IRQ_INPROGRESS. Because irq_set_chained_handler_and_data() clears handler_data before masking the parent IRQ, a racing interrupt on another CPU can dereference NULL: CPU0 CPU1 imx_intmux_teardown_channel() disable_irq(irq) __irq_disable(desc, false) /* SPI still unmasked */ irq_set_chained_handler_and_data( irq, NULL, NULL) desc->...handler_data =3D NULL imx_intmux_irq_handler(desc) irqchip_data =3D NULL irqchip_data->chanidx <-- NULL pointer dereference __irq_do_set_handler(..., NULL) mask_ack_irq(desc) If imx_intmux_irq_handler() reads handler_data just before it is cleared, irq_dispose_mapping() installs no_irq_chip before synchronize_irq(), losing the GIC active-state check so teardown can disable ipg_clk and free intmux_data while the handler is still running. Setting IRQ_DISABLE_UNLAZY on the parent IRQ before calling disable_irq() would ensure the parent SPI is masked in hardware before synchronize_irq() runs. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203-imx-intmux= -v2-0-a6db1eed3b5f@nxp.com?part=3D8