]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: dsa: microchip: ptp: Fix checks on irq_find_mapping()
authorBastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
Thu, 20 Nov 2025 09:12:01 +0000 (10:12 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 6 Dec 2025 21:25:01 +0000 (06:25 +0900)
commit 9e059305be41a5bd27e03458d8333cf30d70be34 upstream.

irq_find_mapping() returns a positive IRQ number or 0 if no IRQ is found
but it never returns a negative value. However, during the PTP IRQ setup,
we verify that its returned value isn't negative.

Fix the irq_find_mapping() check to enter the error path when 0 is
returned. Return -EINVAL in such case.

Cc: stable@vger.kernel.org
Fixes: cc13ab18b201 ("net: dsa: microchip: ptp: enable interrupt for timestamping")
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
Link: https://patch.msgid.link/20251120-ksz-fix-v6-2-891f80ae7f8f@bootlin.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/dsa/microchip/ksz_ptp.c

index 050f17c43ef60de962ecd34d8171960346ffcd48..6d06cb1f8497e5e58ed1c310e24c70c59b559587 100644 (file)
@@ -1145,8 +1145,8 @@ int ksz_ptp_irq_setup(struct dsa_switch *ds, u8 p)
                irq_create_mapping(ptpirq->domain, irq);
 
        ptpirq->irq_num = irq_find_mapping(port->pirq.domain, PORT_SRC_PTP_INT);
-       if (ptpirq->irq_num < 0) {
-               ret = ptpirq->irq_num;
+       if (!ptpirq->irq_num) {
+               ret = -EINVAL;
                goto out;
        }