From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=80.86.107.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796524219; b=KjaiVy49MG9MUHC2RwHzHclY/56U+1Mi2VUY9kpwSSSjfa54crpJFS+xEYZevEigg4Zr trrLXuorCEpwcR3T5HoOUygx9ECyvJdc48zfHrpyu6F+uJwZlRDxwBbwXG0Rnpi+VUPTr fYq9wObOLVRKyx8sgGx9UkTye7qLWtHv6dn1RzxDWC+Qn3ceq7oTpUsX5bglImomAk8k1 PEsAeZP2aPuzVsMKRMjuN/Gfipipg6KyOJXSEKPAr96mn4x/4+DRyp8PpYgKDyupMN+9r zetnnvZyxJEtAMUdhu19HDfBXVIgbb/dJdjKXrAxJjRipFngaBTwBqJeAqAQX7bU45g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796524219; h=DMARC-Filter:DKIM-Signature:Received:Message-ID:Subject:From:To:Cc: Date:In-Reply-To:References:Content-Type:Content-Transfer-Encoding: User-Agent:MIME-Version; bh=L/a1EvxvZhtdCK+BjVObALTH6bkg+G3plZ8gIAJs+w0=; b=pzGPJL3jZFNb9aIik2BchAY6e3ckujoKnwxIQXodhImYJmIplcDnBXQEJWLlRfVeknvT 1hwu23wzcEgaqb4+2DkUckHrDjdSLL8pr43+J2t5M/4JqmFrvBXk+PaK2usRIc6FW0GAT bUfDkl/dJtLL8gilRSElw+P4eCPAbgXIErwFlMF2n6p687dleYqGXVBEiNommG3Pb6P2g 7biPhcJUp1xUYr+RmCNlWr45DB0nrzvgC3mNET/TgD9CiTWv3XGaB/KKzUBZfyqB2Ebg2 U53WuKCr5xyp2MFeSx0B4FkC34hsPy6U2ZOd+Lk/ny/+ZSyRZPq8YX4GsolX32qjIsw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=rendec.net; spf=pass smtp.mailfrom=rendec.net; dkim=pass header.d=rendec.net header.i=@rendec.net header.a=rsa-sha256 header.s=default header.b=QqHYlcvy; arc=none smtp.remote-ip=80.86.107.70 Received: from mail.mindbit.ro (xs1.mindbit.ro [80.86.107.70]) (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 3EF9C606A322; Sun, 6 Dec 2026 02:30:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3EF9C606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=rendec.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rendec.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=rendec.net header.i=@rendec.net header.a=rsa-sha256 header.s=default header.b=QqHYlcvy DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rendec.net; s=default; t=1796524209; bh=T/2X/EIPla8Wr/tyaQi4hzEvGPevNGxfWr69jkle8zo=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=QqHYlcvyPiy6975B/rf6EkAoCKkzEK+GBBcwO42mfnYrNXFGxXWa6BrgYvjUPhnYi OagweLl73s9iSN+aR1WT7hkpXsPiko3F3EHyu8eiVtmo8Q6dv6OZTaBqrF1UOWF7kO W/ufamRqp53WM0m/b7Fl0PeDy+w0rvQgYuvhbn0qjggf3ccAU05B5+1H4UoEqYGtJK KPl7MTR/x0ZovATRmWhvYkwE8kdVCRet7BOoVnZkHmjUwZ4UhRmqZVSUWEriHoAPGi E5zMLGUyNLAL98znUFxSVon8NBFB4n+XknxAGNsXKapJeFN1iUUMF26coVF+f7kT8J nJ0jrUNl12GZA== Received: from [172.16.1.1] (pool-174-112-193-187.cpe.net.cable.rogers.com [174.112.193.187]) by mail.mindbit.ro (Postfix) with ESMTPSA id EBE871C00FA; Sun, 06 Dec 2026 04:30:08 +0200 (EET) Message-ID: <1efb1571c28144ad5ea5604ad7e7256fd254c260.camel@rendec.net> Subject: Re: [PATCH] irqchip/renesas-rzv2h: Fix potential stale state on probe failure From: Radu Rendec To: Guangshuo Li , tglx@kernel.org Cc: prabhakar.mahadev-lad.rj@bp.renesas.com, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org Date: Sat, 05 Dec 2026 21:30:06 -0500 In-Reply-To: <20261202-85cdeb22ca-irqchip-renesas@mail.sdu.edu.cn> References: <20261202-85cdeb22ca-irqchip-renesas@mail.sdu.edu.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2-0+deb13u1 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 On Wed, 2026-12-02 at 19:30 +0800, Guangshuo Li wrote: > An IRQ setup failure releases the managed controller data but leaves its > domain and syscore callbacks registered. Partially created IRQ mappings > also retain controller pointers. >=20 > Dispose of each mapping after its managed handler is released, then > remove the domain. Register the syscore callbacks only after IRQ setup > succeeds. >=20 > This issue was found by our static analysis tool under development. >=20 > Fixes: 61adc4813d67 ("irqchip/renesas-rzv2h: Add CA55 software interrupt = support") > Signed-off-by: Guangshuo Li > --- > =C2=A0drivers/irqchip/irq-renesas-rzv2h.c | 28 ++++++++++++++++++++++++++= -- > =C2=A01 file changed, 26 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/irqchip/irq-renesas-rzv2h.c b/drivers/irqchip/irq-re= nesas-rzv2h.c > index 806be528b6d4..d9b9d82e44c2 100644 > --- a/drivers/irqchip/irq-renesas-rzv2h.c > +++ b/drivers/irqchip/irq-renesas-rzv2h.c > @@ -793,6 +793,16 @@ static irqreturn_t rzv2h_icu_swint_irq(int irq, void= *data) > =C2=A0 return IRQ_HANDLED; > =C2=A0} > =C2=A0 > +static void rzv2h_icu_remove_domain(void *data) > +{ > + irq_domain_remove(data); This has the same problem I flagged a week ago when I reviewed your other series: it removes the domain without disposing of the irq mappings. When it's called because probe() fails, it's probably not an issue because no downstream interrupts exist at that point. But the devres binding survives the probe(), so at least in theory your remove callback can be called later with active mappings. > +} > + > +static void rzv2h_icu_dispose_mapping(void *data) > +{ > + irq_dispose_mapping((unsigned long)data); > +} > + > =C2=A0static int rzv2h_icu_setup_irqs(struct platform_device *pdev, struc= t irq_domain *irq_domain) > =C2=A0{ > =C2=A0 const struct rzv2h_hw_info *hw_info =3D rzv2h_icu_data->info; > @@ -815,6 +825,11 @@ static int rzv2h_icu_setup_irqs(struct platform_devi= ce *pdev, struct irq_domain > =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 "failed to create int-ca55-%u IRQ map= ping\n", i); > =C2=A0 } > =C2=A0 > + ret =3D devm_add_action_or_reset(dev, rzv2h_icu_dispose_mapping, > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (void *)(unsigned long)virq); > + if (ret) > + return ret; > + > =C2=A0 ret =3D devm_request_irq(dev, virq, rzv2h_icu_swint_irq, 0, dev_n= ame(dev), > =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (void *)(uintptr_t)i); > =C2=A0 if (ret) > @@ -844,6 +859,11 @@ static int rzv2h_icu_setup_irqs(struct platform_devi= ce *pdev, struct irq_domain > =C2=A0 if (!virq) > =C2=A0 return dev_err_probe(dev, -EINVAL, "failed to create icu-error-ca= 55 IRQ mapping\n"); > =C2=A0 > + ret =3D devm_add_action_or_reset(dev, rzv2h_icu_dispose_mapping, > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (void *)(unsigned long)virq); > + if (ret) > + return ret; > + > =C2=A0 ret =3D devm_request_irq(dev, virq, rzv2h_icu_error_irq, 0, dev_na= me(dev), rzv2h_icu_data); > =C2=A0 if (ret) > =C2=A0 return ret; > @@ -901,14 +921,18 @@ static int rzv2h_icu_probe_common(struct platform_d= evice *pdev, struct device_no > =C2=A0 goto pm_put; > =C2=A0 } > =C2=A0 > - rzv2h_icu_data->info =3D hw_info; > + ret =3D devm_add_action_or_reset(dev, rzv2h_icu_remove_domain, irq_doma= in); I understand why you did this, but I personally don't like the proliferation of explicit devm_add_action_or_reset() calls. I'm working on a patch series that adds a devres managed variant of irq_domain_create_hierarchy() and attempts to also solve the automatic disposal of irq mappings. I hope to be able to post it within the next couple of days, so perhaps it's better to wait for it. > + if (ret) > + goto pm_put; > =C2=A0 > - register_syscore(&rzv2h_irqc_syscore); > + rzv2h_icu_data->info =3D hw_info; > =C2=A0 > =C2=A0 ret =3D rzv2h_icu_setup_irqs(pdev, irq_domain); > =C2=A0 if (ret) > =C2=A0 goto pm_put; > =C2=A0 > + register_syscore(&rzv2h_irqc_syscore); > + > =C2=A0 /* > =C2=A0 * coccicheck complains about a missing put_device call before ret= urning, but it's a false > =C2=A0 * positive. We still need dev after successfully returning from t= his function. >=20 > base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244