From nobody Sun Feb 8 01:51:59 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A83D62BE632 for ; Fri, 14 Nov 2025 07:20:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763104839; cv=none; b=Y3BBaMwCi5MJLdH9pvNBsjQHZSY/IKmo2fKztT4TMH+g5m3JIwP89GOj6on7L599W67Dbp+CJUnNbu27wl9Yw+VwaV5Q+KXWkp/jIncuBRLnOyJ00wSwY93N2mi1c7/KrdTS3NgK872XZHaFoxD39R24l93YuVzeGaLDpAapqhk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763104839; c=relaxed/simple; bh=bA81shltpQIqo6ERwe+YEEDiuPrqc/y6ChY0B4cSbI8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tPuomU405HiIeFa1m5nLIgB+ux7fEpAaKpnr7/iirPjM8BQF014vbPpBcKovPAtP2GknQ8edc6/gf4k44izqtjXBuVml38C8GXRJoLfh2ahrrrHpTdqcKAGtbE5DR1CnmmIzWkDnYwiKey/5B1RDJwwMgB/HBlTIJE2lyCPNE5E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=fEVKbwMf; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="fEVKbwMf" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 10D5DC10F5B; Fri, 14 Nov 2025 07:20:07 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id CE2E56060E; Fri, 14 Nov 2025 07:20:28 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B198A102F27C7; Fri, 14 Nov 2025 08:20:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763104828; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=JWi0y84NUpIkh/iErh4hngLnIokL0fky07nZkrhPRJc=; b=fEVKbwMfVc7aKOdKe4z+6mtD+AyLbUv/ysVYDkAkX0X5qo1FvJGhq+oHAwYJ84shynfYCT ZHn0Phc3qn/rI7gyQwKtN4AxuOWjZIBFMlA3ZyWowXIjuC0EptssI0OwzPaLQ9ucuphKs2 e2MNUrE7hn3pgeZcwb5eeQZIBQA+tYfoELq2uhsE6h6cHvW2EKlA8cdm12iAXDrN/5Koe+ qYtckMU7Z6Uo9LwKY7Rc8iPTuJqTh3Mm0DX66Xk649qvg4TgyxkgwOfuOgYpADvt0+uJFM eZKWYYrpJoiRwUGAImB4Vsbmc2OpjXIZdD81Ps/odSoMJP14bTC1WKx1Cp0bhA== From: "Bastien Curutchet (Schneider Electric)" Date: Fri, 14 Nov 2025 08:20:20 +0100 Subject: [PATCH net v3 1/4] net: dsa: microchip: common: Fix checks on irq_find_mapping() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251114-ksz-fix-v3-1-acbb3b9cc32f@bootlin.com> References: <20251114-ksz-fix-v3-0-acbb3b9cc32f@bootlin.com> In-Reply-To: <20251114-ksz-fix-v3-0-acbb3b9cc32f@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Arun Ramadoss Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.2 X-Last-TLS-Session-Version: TLSv1.3 irq_find_mapping() returns a positive IRQ number or 0 if no IRQ is found but it never returns a negative value. However, on each irq_find_mapping() call, we verify that the returned value isn't negative. Fix the irq_find_mapping() checks to enter error paths when 0 is returned. Return -EINVAL in such cases. Fixes: c9cd961c0d43 ("net: dsa: microchip: lan937x: add interrupt support f= or port phy link") Signed-off-by: Bastien Curutchet (Schneider Electric) Reviewed-by: Andrew Lunn --- drivers/net/dsa/microchip/ksz_common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index a962055bfdbd8fbfc135b2dec73c222a213985c4..3a4516d32aa5f99109853ed400e= 64f8f7e2d8016 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -2583,8 +2583,8 @@ static int ksz_irq_phy_setup(struct ksz_device *dev) =20 irq =3D irq_find_mapping(dev->ports[port].pirq.domain, PORT_SRC_PHY_INT); - if (irq < 0) { - ret =3D irq; + if (!irq) { + ret =3D -EINVAL; goto out; } ds->user_mii_bus->irq[phy] =3D irq; @@ -2948,8 +2948,8 @@ static int ksz_pirq_setup(struct ksz_device *dev, u8 = p) snprintf(pirq->name, sizeof(pirq->name), "port_irq-%d", p); =20 pirq->irq_num =3D irq_find_mapping(dev->girq.domain, p); - if (pirq->irq_num < 0) - return pirq->irq_num; + if (!pirq->irq_num) + return -EINVAL; =20 return ksz_irq_common_setup(dev, pirq); } --=20 2.51.1 From nobody Sun Feb 8 01:51:59 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BF552EDD7D for ; Fri, 14 Nov 2025 07:20:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763104840; cv=none; b=a/WhcX7hkAWxmKITSpNoT4w3pvdmTZhyoc6Xbb/NgCaKDAsn5/4P2LdgHTetYETqJhjnUJW1o7V/cXu6pzW1hK6Dx+72hLMiCWV0XU/YUp9rqOjdCTEUP/WGe6G12UqrgYOHDpMZhqbUEWO5gFPlOW+oxCRVfxFwbW4UjGFkH9A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763104840; c=relaxed/simple; bh=Jl90UdEr8NC9NQJHRyLWV6kpPFz4gyUYS0h9z2g368U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=J3Aw2xnd3uZ7eE/F0IpiVtLlu1K596wF5s1eqCjY4lxxTITFZQWa7tfBOU4stBsq+eYG3aDhWq73POqPsNL7G6OchwHl/3HyvF3H74Gqxpmx5TrKLWXtOB0cs4JVggu+IHTgCFpGAzg8PKgkOZUT5pvKpQYTe5prvJzki7NGSc8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=dVnGOGwc; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="dVnGOGwc" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id B2A36C10F5E; Fri, 14 Nov 2025 07:20:08 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 7DFD16060E; Fri, 14 Nov 2025 07:20:30 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 45D2F102F291C; Fri, 14 Nov 2025 08:20:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763104829; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=RTnapVv6Kq237V0+NqTV4P/zgR2L1d18jSkpYpEllMQ=; b=dVnGOGwcwe4M9KEGgf15/UOcqd1SPIo96q37GYcbRYtmy0B2ccfF/RdtZvcoumyWoPfCfd OS69ACjkAZwiCkLZ58uGj5qXi/IhXSnAd9cTu1Ub20jH0KsTLrB3cBwdItBtfRBqFqxGNE XXZk6qXMWi17PLha5ypKe+liMVnl1cgFSpaXr9fLnnxnCmjxJgquhrK+8cRdgcdJPk8u7Y JhCeQ8I3pHnEqQUit3O4IQEv6h4+JXevwb18G6WCYARXw0UyAQLIjO4lfsvwBFLkLn4kE0 XsTHw7fo0CHzCe964iO7F5fdXpmlVw1es0XV1kME6eTdIKEZJN/623UuHsWCpQ== From: "Bastien Curutchet (Schneider Electric)" Date: Fri, 14 Nov 2025 08:20:21 +0100 Subject: [PATCH net v3 2/4] net: dsa: microchip: ptp: Fix checks on irq_find_mapping() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251114-ksz-fix-v3-2-acbb3b9cc32f@bootlin.com> References: <20251114-ksz-fix-v3-0-acbb3b9cc32f@bootlin.com> In-Reply-To: <20251114-ksz-fix-v3-0-acbb3b9cc32f@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Arun Ramadoss Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.2 X-Last-TLS-Session-Version: TLSv1.3 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. Fixes: cc13ab18b201 ("net: dsa: microchip: ptp: enable interrupt for timest= amping") Signed-off-by: Bastien Curutchet (Schneider Electric) Reviewed-by: Andrew Lunn --- drivers/net/dsa/microchip/ksz_ptp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchi= p/ksz_ptp.c index 35fc21b1ee48a47daa278573bfe8749c7b42c731..c8bfbe5e2157323ecf29149d190= 7b77e689aa221 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.c +++ b/drivers/net/dsa/microchip/ksz_ptp.c @@ -1139,8 +1139,8 @@ int ksz_ptp_irq_setup(struct dsa_switch *ds, u8 p) irq_create_mapping(ptpirq->domain, irq); =20 ptpirq->irq_num =3D irq_find_mapping(port->pirq.domain, PORT_SRC_PTP_INT); - if (ptpirq->irq_num < 0) { - ret =3D ptpirq->irq_num; + if (!ptpirq->irq_num) { + ret =3D -EINVAL; goto out; } =20 --=20 2.51.1 From nobody Sun Feb 8 01:51:59 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3E452F5A30; Fri, 14 Nov 2025 07:20:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763104841; cv=none; b=Fg2aKipODWbcB/KHkeoymuRZUT0qpBQE0vA0PJMFO4dbtVNSyG+jFaH7/cUBdePAptRsub/ViRKTaozUt0pW9Q/MIF+0ucOdOM5ZVoxccrmReARihm0nrI48JP6RsaGrKFqmO3xSupnH45omZo/ooM1JEFhkmYWis7rjX8sFxb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763104841; c=relaxed/simple; bh=n2hvB/3o5w8dPESHdtFQQ9OaOCEwb0lAWC9CkO0kdaY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aweSkd+XfbuMMWt000C98U0WUMAhNWR83VpSIxm5cHbFRD5815IDVEIjNpASWJdgSfnCnT5SgeSrfBsgu28JxbrY5rKottdtLrCrqH/eJCHiarB+4hsNJNxXJDSKS6xtJUYuaKyjMdqSCP7I2pCZaqeLjctvQf48Er07hshC01k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=SU5Udwbv; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="SU5Udwbv" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 67D8A1A1A97; Fri, 14 Nov 2025 07:20:32 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 36EFB6060E; Fri, 14 Nov 2025 07:20:32 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id E5F3F102F24BE; Fri, 14 Nov 2025 08:20:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763104831; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=XSXVbFwfTU7Uju3hufcbql/zxc9UUbIw1e56ZFVut6Y=; b=SU5UdwbvnTqhlnvB5uPaGxGoTqyTYLEuoabB45YUjwmE63IS2KW2DcLR/iGiRf7FguMKJt cSmygxIUNeC6GXVaYeIfoPvt+H4aXh8DPfidX6VQPuonVwUEv+i/DLc/HVWOPmfOSKJ70U JZEz3J1fKSrF7FuC731lQS3B+XL72KQrtvx/isTGUzq23c6H+GsNiCuUXiwFEgTEo7xHeq OJn2OUbJl3sUDxUkIn7i5L003SM0kNhJZrtroCeLj38xupIWWgpMtFLmtDAN9cc3kkby1V cg/K8RhbDM8L4N3PGkQPmhbaP5kgwEAgyV4YXtu4YY/xoDwfrEgTRCnLnAHHlw== From: "Bastien Curutchet (Schneider Electric)" Date: Fri, 14 Nov 2025 08:20:22 +0100 Subject: [PATCH net v3 3/4] net: dsa: microchip: Ensure a ksz_irq is initialized before freeing it Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251114-ksz-fix-v3-3-acbb3b9cc32f@bootlin.com> References: <20251114-ksz-fix-v3-0-acbb3b9cc32f@bootlin.com> In-Reply-To: <20251114-ksz-fix-v3-0-acbb3b9cc32f@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Arun Ramadoss Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.2 X-Last-TLS-Session-Version: TLSv1.3 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 timest= amping") Signed-off-by: Bastien Curutchet (Schneider Electric) -- 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 --- drivers/net/dsa/microchip/ksz_common.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 3a4516d32aa5f99109853ed400e64f8f7e2d8016..c5f8821a3a0ab7b50ddc31cc0a2= f28220fe57c84 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -2858,14 +2858,17 @@ static void ksz_irq_free(struct ksz_irq *kirq) { int irq, virq; =20 - free_irq(kirq->irq_num, kirq); + if (kirq->irq_num) + free_irq(kirq->irq_num, kirq); =20 - for (irq =3D 0; irq < kirq->nirqs; irq++) { - virq =3D irq_find_mapping(kirq->domain, irq); - irq_dispose_mapping(virq); - } + if (kirq->domain) { + for (irq =3D 0; irq < kirq->nirqs; irq++) { + virq =3D irq_find_mapping(kirq->domain, irq); + irq_dispose_mapping(virq); + } =20 - irq_domain_remove(kirq->domain); + irq_domain_remove(kirq->domain); + } } =20 static irqreturn_t ksz_irq_thread_fn(int irq, void *dev_id) --=20 2.51.1 From nobody Sun Feb 8 01:51:59 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0171125F988 for ; Fri, 14 Nov 2025 07:20:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763104838; cv=none; b=L3ISBjXStia/71BIOHAXmGKv5wfpVJmvkhstxhjVAAg3By/23ARsYuxd5315MYvCqH8ZVUvza+y8zbcSYjVQIlLWDMK4i4lmx44EDDV3bS9fUA8gTUSFvz5dRVWk3at/0pwrxOSN/7Xd+MvtXfskx3Dbt4iKWzv7bPqdMVI2AEE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763104838; c=relaxed/simple; bh=NGRwkgSxolK/2c9dDLpj5CBW0FVd4LmMQwPSXORDZoY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MYRXO5oDIR1HcCJj7+3GcqYkkuhsB1cwbTWo9LGoUMJNenHHmg1RUFVmCZ2hGuQH6AWnfPqg7TX0TAIbNknlnkMtFiy5b5XGV1Qyil0WDsHHpe3cV0xwDwgW60//FIKjl/OcgdT4w2F0gGpfsXc0Po8sPf1iqAj9FVQtSBLkCYo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=UdoxGSHG; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="UdoxGSHG" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 080234E416AF; Fri, 14 Nov 2025 07:20:34 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id CC45D6060E; Fri, 14 Nov 2025 07:20:33 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 9C172102F292F; Fri, 14 Nov 2025 08:20:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763104833; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=IO1xnDzOycn8GAViF9q7Sa/lIVw19nSLvwRtLk30Ywc=; b=UdoxGSHGz5bOyPjqKHdiAmIhGwIxJTTHvkrUpZOR8GLVX1Bfidvv4QL2INTjpTTcRDLUll IuCgtW4pVXLTe1qUXx7LTHJGPcq+SvVeqa7CDKy1U0Zyrk6D0eoKMUxnJpkys9NO7wApBl xLiFGtJtwimlSmhqgcsFnEpYGgmWa5NXP8zoeirojRwxeycnyR0GSq4R1rRKMssneyyHaf hRKY8T5+ciBnLRbKGqSpY03OheghjiEB4lRXMCwQK+T64NpcslZF5igepfCZsbZVZXnhp4 Sn+rVCru6t4y0TEsN4Ep0xRX/furoO9g77xD++QjCMNJsU5trZjtlTCl0v+Suw== From: "Bastien Curutchet (Schneider Electric)" Date: Fri, 14 Nov 2025 08:20:23 +0100 Subject: [PATCH net v3 4/4] net: dsa: microchip: Immediately assing IRQ numbers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251114-ksz-fix-v3-4-acbb3b9cc32f@bootlin.com> References: <20251114-ksz-fix-v3-0-acbb3b9cc32f@bootlin.com> In-Reply-To: <20251114-ksz-fix-v3-0-acbb3b9cc32f@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Arun Ramadoss Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.2 X-Last-TLS-Session-Version: TLSv1.3 The IRQ numbers created through irq_create_mapping() are only assigned to ptpmsg_irq[n].num at the end of the IRQ setup. So if an error occurs between their creation and their assignment (for instance during the request_threaded_irq() step), we enter the error path and fail to release the newly created virtual IRQs because they aren't yet assigned to ptpmsg_irq[n].num. Assign the IRQ number at mapping creation. Fixes: cc13ab18b201 ("net: dsa: microchip: ptp: enable interrupt for timest= amping") Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz_ptp.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchi= p/ksz_ptp.c index c8bfbe5e2157323ecf29149d1907b77e689aa221..a8ad99c6ee35ff60fb56cc57705= 20a793c86ff66 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.c +++ b/drivers/net/dsa/microchip/ksz_ptp.c @@ -1102,10 +1102,6 @@ static int ksz_ptp_msg_irq_setup(struct ksz_port *po= rt, u8 n) =20 strscpy(ptpmsg_irq->name, name[n]); =20 - ptpmsg_irq->num =3D irq_find_mapping(port->ptpirq.domain, n); - if (ptpmsg_irq->num < 0) - return ptpmsg_irq->num; - return request_threaded_irq(ptpmsg_irq->num, NULL, ksz_ptp_msg_thread_fn, IRQF_ONESHOT, ptpmsg_irq->name, ptpmsg_irq); @@ -1135,8 +1131,13 @@ int ksz_ptp_irq_setup(struct dsa_switch *ds, u8 p) if (!ptpirq->domain) return -ENOMEM; =20 - for (irq =3D 0; irq < ptpirq->nirqs; irq++) - irq_create_mapping(ptpirq->domain, irq); + for (irq =3D 0; irq < ptpirq->nirqs; irq++) { + port->ptpmsg_irq[irq].num =3D irq_create_mapping(ptpirq->domain, irq); + if (!port->ptpmsg_irq[irq].num) { + ret =3D -EINVAL; + goto out; + } + } =20 ptpirq->irq_num =3D irq_find_mapping(port->pirq.domain, PORT_SRC_PTP_INT); if (!ptpirq->irq_num) { --=20 2.51.1