Re: [PATCH net v2 3/4] net: dsa: microchip: Ensure a ksz_irq is initialized before freeing it

Jakub Kicinski
2025-11-11T02:28:41Z

On Thu, 06 Nov 2025 13:53:10 +0100 Bastien Curutchet (Schneider
Electric) wrote:
> diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
> index 3a4516d32aa5f99109853ed400e64f8f7e2d8016..4f5e2024442692adefc69d47e82381a3c3bda184 100644
> --- a/drivers/net/dsa/microchip/ksz_common.c
> +++ b/drivers/net/dsa/microchip/ksz_common.c
> @@ -2858,14 +2858,16 @@ static void ksz_irq_free(struct ksz_irq *kirq)
> {
> int irq, virq;
>
> - free_irq(kirq->irq_num, kirq);
> + if (kirq->irq_num)
> + free_irq(kirq->irq_num, kirq);
>
> for (irq = 0; irq < kirq->nirqs; irq++) {

if the domain may not be registered is it okay to try to find mappings
in it? From the init path it seems that kirq->nirqs is set to the port
count before registration so it will not be 0 if domain is NULL.

> virq = irq_find_mapping(kirq->domain, irq);
> irq_dispose_mapping(virq);
> }
>
> - irq_domain_remove(kirq->domain);
> + if (kirq->domain)
> + irq_domain_remove(kirq->domain);