From: Andrew Lunn <andrew@lunn.ch>
To: "Bastien Curutchet (Schneider Electric)" <bastien.curutchet@bootlin.com>
Cc: "Woojung Huh" <woojung.huh@microchip.com>,
UNGLinuxDriver@microchip.com,
"Vladimir Oltean" <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Richard Cochran" <richardcochran@gmail.com>,
"Arun Ramadoss" <arun.ramadoss@microchip.com>,
"Pascal Eberhard" <pascal.eberhard@se.com>,
"Miquèl Raynal" <miquel.raynal@bootlin.com>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v3 3/4] net: dsa: microchip: Ensure a ksz_irq is initialized before freeing it
Date: Fri, 14 Nov 2025 16:00:21 +0100 [thread overview]
Message-ID: <f13d7a80-d7cc-46c4-99f4-ea42f419b252@lunn.ch> (raw)
In-Reply-To: <20251114-ksz-fix-v3-3-acbb3b9cc32f@bootlin.com>
On Fri, Nov 14, 2025 at 08:20:22AM +0100, Bastien Curutchet (Schneider Electric) wrote:
> Sometimes ksz_irq_free() can be called on uninitialized ksz_irq (for
> example when ksz_ptp_irq_setup() fails). It leads to freeing
> uninitialized IRQ numbers and/or domains.
>
> Ensure that IRQ numbers or domains aren't null before freeing them.
> In our case the IRQ number of an initialized ksz_irq is never 0. Indeed,
> it's either the device's IRQ number and we enter the IRQ setup only when
> this dev->irq is strictly positive, or a virtual IRQ assigned with
> irq_create_mapping() which returns strictly positive IRQ numbers.
>
> Fixes: cc13ab18b201 ("net: dsa: microchip: ptp: enable interrupt for timestamping")
> Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
> --
> Regarding the Fixes tag here, IMO before cc13ab18b201 it was safe to
> not check the domain and the IRQ number because I don't see any path
> where ksz_irq_free() would be called on a non-initialized ksz_irq
I would say the caller is wrong, not ksz_irq_free().
Functions like this come in pairs: ksz_irq_setup() & ksz_irq_free().
_free() should not be called if _setup() was not successful.
Please take a look if you can fix the caller. If the change is big,
maybe we need this as a minimal fix for net, but make the bigger
change in net-next?
Thanks
Andrew
next prev parent reply other threads:[~2025-11-14 15:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-14 7:20 [PATCH net v3 0/4] net: dsa: microchip: Fix resource releases in error path Bastien Curutchet (Schneider Electric)
2025-11-14 7:20 ` [PATCH net v3 1/4] net: dsa: microchip: common: Fix checks on irq_find_mapping() Bastien Curutchet (Schneider Electric)
2025-11-14 14:51 ` Andrew Lunn
2025-11-14 7:20 ` [PATCH net v3 2/4] net: dsa: microchip: ptp: " Bastien Curutchet (Schneider Electric)
2025-11-14 14:51 ` Andrew Lunn
2025-11-14 7:20 ` [PATCH net v3 3/4] net: dsa: microchip: Ensure a ksz_irq is initialized before freeing it Bastien Curutchet (Schneider Electric)
2025-11-14 15:00 ` Andrew Lunn [this message]
2025-11-17 8:51 ` Bastien Curutchet
2025-11-14 7:20 ` [PATCH net v3 4/4] net: dsa: microchip: Immediately assing IRQ numbers Bastien Curutchet (Schneider Electric)
2025-11-14 15:11 ` Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f13d7a80-d7cc-46c4-99f4-ea42f419b252@lunn.ch \
--to=andrew@lunn.ch \
--cc=UNGLinuxDriver@microchip.com \
--cc=arun.ramadoss@microchip.com \
--cc=bastien.curutchet@bootlin.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=pascal.eberhard@se.com \
--cc=richardcochran@gmail.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=woojung.huh@microchip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®