From nobody Fri Dec 19 15:49:17 2025 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 B8C2932C936 for ; Thu, 6 Nov 2025 12:53:19 +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=1762433601; cv=none; b=tZFeADmXYI4aw/VU88hdQE3ceH1NyRiqXL7RvLBtE/t2lSUXBbMDdIDgla0ACnxJOkdXGPwmURd57kpdsMD848p+0xzynh9cVm84exf3hcnAyzkcEW4pVJTvtXQdyyN+/5GrpzlzhPZScyu+hpGKAwSiKk7gO63jG94h02eVW00= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762433601; c=relaxed/simple; bh=7iYJ58BtlFxh5N4iUZr364GIyx6CI8EugINx7k/GPGU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sA5otsbceNRxo7PU8wcxJEyVrf2JfQj85ttfjpc1Lr6YK152y0s/f8zBTWYTZH0K1TmgjSz8JPryGUDx6RetGCYTXUAzvNgLDYLmzkZS3LRXtdHUTij8SCW1bfySlobAKVgRCOrJc/rD3V1h8E5McRlnkRWBADArALHXFSjKjmg= 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=KfTiNcb2; 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="KfTiNcb2" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id E3E844E4156D; Thu, 6 Nov 2025 12:53:17 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id B90046068C; Thu, 6 Nov 2025 12:53:17 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B57F011851026; Thu, 6 Nov 2025 13:53:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1762433597; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=1kW23ym1qnGitde+ICvZliYafoUJFTsz+cQqqnstk2I=; b=KfTiNcb2SktS5gXFxeLxKb2KcDHFrbuTj/xhx2G47u3EY0Js6ZdMP/cVC7nHOWHyLxyoCU uIWVCJ5f8DCfd6D3jZor15lECxcarAOFsgQ19lF5fp+r3Yjp9gNGcaH/6TqflWn20w/6VV x0+6/DLsFCQHMkRR1as/ayxbcXCFoIlssAWqnH1gk4aHM7r2KP843m1gF0d4avyWQS/9GF nAd3Ph8dZKSXsI7/gmLtoqM9fLgO8378VAPoXunRGGDvtgNdXx9z2l9SbAc4vW9+dFahJr UKuzTDrc/+ChxqLkm+Thr42JGlrP9FG2G2sMHpmn1IW/Yuw++1FhLOTmLQm4og== From: "Bastien Curutchet (Schneider Electric)" Date: Thu, 06 Nov 2025 13:53:08 +0100 Subject: [PATCH net v2 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: <20251106-ksz-fix-v2-1-07188f608873@bootlin.com> References: <20251106-ksz-fix-v2-0-07188f608873@bootlin.com> In-Reply-To: <20251106-ksz-fix-v2-0-07188f608873@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: ff319a644829 ("net: dsa: microchip: move interrupt handling logic fr= om lan937x to ksz_common") Signed-off-by: Bastien Curutchet (Schneider Electric) --- 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.0 From nobody Fri Dec 19 15:49:17 2025 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 24A5832C956 for ; Thu, 6 Nov 2025 12:53:20 +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=1762433603; cv=none; b=buutqxVB28q3Wnu46CB1Mn/cxR+tcyoa2GC3vyGIYJm1C0BAufPIExD4OVc8O5vyquHro3O6RJErOiTgb03D3fzuL5uLUn4fsUlob3QdHcjyhJ3Pf/Df/CNKxOu4On27TMu3gzY+f6z5tmZZh5/ZvDvSTwRbLrwUQpKOcuWGTdM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762433603; c=relaxed/simple; bh=DgaEBzJVE0diUpcGF2jdqQ0yAib13/RGrDpfzFmIiKQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=V9qZzQ02v9cjRVxPm7nZFNMu1/FrlO5p9z0wak8fZcX325fhG4giEw3yvkWPhPCvwaGL+/jn8enwbZSooHVg9oMgGQVbbkK54rinHKzP8jWTC9kdy1mvkEBZ/lmwJnrHQjyNp5h9SPL9+nRk8FLAIP0Dfn88L4IkOK2lLJuIky4= 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=g3EOW+eG; 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="g3EOW+eG" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 5602C4E41460; Thu, 6 Nov 2025 12:53:19 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 2B4CB6068C; Thu, 6 Nov 2025 12:53:19 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 4CED71185102A; Thu, 6 Nov 2025 13:53:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1762433598; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=U52A0foBkCvgyCUwDdVQ7zTmGiYooyVZixhAGJ0JZp4=; b=g3EOW+eGxuVNT5I+V9nxHKZM18Y6DjUN+oYkr6K8uOh0+Z5Rng0mL9EF/XsCp3l0I4El5Z RvoQOXMJ/w7MKzF3mkM3EGSlvcRbULcte5qOoyAzckRtS5hgQ43f4QMtxnnZaxGvukc7PZ 5HdWDsprEhGYHT5dja3XpvBzXtsTdzI9zi6PPfSSpte81N4lXW8XNBE2KpoNStGU6GnfF1 IQ3XYO6Xh5vATkXfiqEQEFUksRAI/rzX4MLVG/CX1wcwfaUDv5/vPPvbyhvkmgA5d7oGG/ FYUnzoyFn6oXilNo/lrzmIMR/lmQ/Hr6M35hI+dM5WURyht8M+NMzffiZq9oAg== From: "Bastien Curutchet (Schneider Electric)" Date: Thu, 06 Nov 2025 13:53:09 +0100 Subject: [PATCH net v2 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: <20251106-ksz-fix-v2-2-07188f608873@bootlin.com> References: <20251106-ksz-fix-v2-0-07188f608873@bootlin.com> In-Reply-To: <20251106-ksz-fix-v2-0-07188f608873@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) --- 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.0 From nobody Fri Dec 19 15:49:17 2025 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 88622332917 for ; Thu, 6 Nov 2025 12:53:22 +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=1762433604; cv=none; b=fY39jnaFqwGOrvLcOTG/rULsCVgtRAYZ2MMmZbOa3f0XI/yWAMgPOnhrHw8fMJzUUSqiPZ9D9JxwG7akjZ0Gc7DoUVCYZsKmHdZVw2EVax4FU4ugay18wJBXUI5B2+pAWxyHaltSqO7d/JOMShfwhEuuxV4aQl4DX2xC1sopqHc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762433604; c=relaxed/simple; bh=IAaIMkOnqP2yloVzJOFVv/QTLiRSqkCSV8+zencdd4s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cJ5LXp7HmpQvO7YByAljERwrBJ43/qemXT7QuGTob2jw2nAxMTm66AayZDVKWGAa67xYiLBIl3kFabS0iQVU4WQgwIIRFxfyGaExGICM98SuxSlJtEFenP4fLWqkCYhdwDS83umzfxVgQ9Pjtsmims8TLnJL+OLU45El59rPUqI= 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=1zH71d0M; 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="1zH71d0M" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 9F36CC0FA8D; Thu, 6 Nov 2025 12:52:59 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id AFD316068C; Thu, 6 Nov 2025 12:53:20 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B08AE11851002; Thu, 6 Nov 2025 13:53:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1762433600; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=UTk0YczWZdiIENouofLZQdqIekWw5Y2Zi1fG/iQ0Rt4=; b=1zH71d0M/LpIaFgT6oh7yWVAu/kdssPt1TBo5Txmn1r6h6qEHJATGLa4gz/v+gzcVPSaxH 9I6m3I6h6eVO5p9BEJfd+m9PFwgZqfmt9C0IlNsLCLZFCUD2qsSfw8bJSNxgu8umSWoMWJ mLBmy4RfjSH3n8pK/4BZ0B1XhMuF9QsBCWYpTfV8N0ce70VKrJyjfFNbREQQVl3E1sGfZb FQOzKI5JD0EaWdyYOTHiqWrHLZSHQ8yAQUYZzOruxat1/0XMq15xvwuaJ28hDgl4KwCwDR NkF79fvUNiUEvp0V2QgwB/775zVcVrxdcUjbN/l0Yer0UmdiLSYM2cY5pjX9cQ== From: "Bastien Curutchet (Schneider Electric)" Date: Thu, 06 Nov 2025 13:53:10 +0100 Subject: [PATCH net v2 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: <20251106-ksz-fix-v2-3-07188f608873@bootlin.com> References: <20251106-ksz-fix-v2-0-07188f608873@bootlin.com> In-Reply-To: <20251106-ksz-fix-v2-0-07188f608873@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: e1add7dd6183 ("net: dsa: microchip: use common irq routines for girq= and pirq") Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz_common.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 3a4516d32aa5f99109853ed400e64f8f7e2d8016..4f5e2024442692adefc69d47e82= 381a3c3bda184 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; =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); } =20 - irq_domain_remove(kirq->domain); + if (kirq->domain) + irq_domain_remove(kirq->domain); } =20 static irqreturn_t ksz_irq_thread_fn(int irq, void *dev_id) --=20 2.51.0 From nobody Fri Dec 19 15:49:17 2025 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 866E3333448 for ; Thu, 6 Nov 2025 12:53:23 +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=1762433605; cv=none; b=ceDWgJYTU8IJsQhvcQTesx/fjiRG8W3NbVxRAEilbQeOMfSauDBmLwH1M2FPxCUn+fLj+j7PpqM6ZlbBP5Zt3iqZVxyW/gPpdkP7T0hOX0fJ/udyPX8+UCjL9Sbo2fjPk2cYanhf/4M2tz9KN5PevHW/9NZKZFKvA/JYnuaNGac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762433605; c=relaxed/simple; bh=gt5H4rVHnAPE0oemZIv7zqZ6B2+MOlDhA/XvwMT0PVg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Cr2CuNLSVDJqgOKvvtF8tuNZCE+95jFMSwxAcB+Swebn0IaTymiJKuof9zFmtlEBojFMk8fn8xhF8OvlQlV+gtIPLYYMtDLPGCKQolOqcMRKQKUlZlSF/dvukIw/amEG7uRJoyDAjlzGFQ12ruFmd3vpQG/W1kkBMa+r+GcXMGw= 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=mjiNlnZq; 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="mjiNlnZq" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 1B82CC0FA8A; Thu, 6 Nov 2025 12:53:01 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 2D3986068C; Thu, 6 Nov 2025 12:53:22 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 45AB111851035; Thu, 6 Nov 2025 13:53:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1762433601; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=aYT5CBgRRZjbjQjWuTTIforvN8cPnOUXp5WDBhMNj1g=; b=mjiNlnZqdfEdHoc7ZKr9doLyplhMa8hTPj6h7JPknnsakekKVaR2x/JOrMyC4WTkTUSDqK 2J4HmLmM5Dthc/SjhBHioxifIg4b2L0SGN+EMtvrghzw27JY/OmmLWNV3i7bv2qec45/K8 y1rtCOSNLqjaHqpAxRbChmAydTaG/z5unpmRrbeqRd0TmWBlXfDsP6HyVuXtJIShA7lvvn F+64f95zvJq4NP1+VcEtJNdlanKllv89GWwDbOrIP1Mp1jWQLbbHyrovr1YbwFjMosPuEs kk4OBFKaIbI3iwRBt5SzBivzUfvPKAiSTtTgGhaMfbxsiDTWuZYkbuY+3GJ0uA== From: "Bastien Curutchet (Schneider Electric)" Date: Thu, 06 Nov 2025 13:53:11 +0100 Subject: [PATCH net v2 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: <20251106-ksz-fix-v2-4-07188f608873@bootlin.com> References: <20251106-ksz-fix-v2-0-07188f608873@bootlin.com> In-Reply-To: <20251106-ksz-fix-v2-0-07188f608873@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.0