From nobody Fri Dec 19 17:17:37 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