From nobody Tue Dec 2 02:19:51 2025 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 9CD5B3148CD; Thu, 20 Nov 2025 09:12:18 +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=1763629941; cv=none; b=ha6md6iHu5O25SpNluobNa5ucLmnQV2xfJhXwPTQs9xWMy4Y0t1OrhaVEn2G1Vj8T4DFhYSdNfG+tDF38Oxg73cmlZeufMUVIx0vDnSvpvszB/dad6oDz/R4T1/u8LhfgCYGNNjGsiQBwHv8KQG3d6txb5UXvZyM7IYgQqDvv7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763629941; c=relaxed/simple; bh=R2ZCVf/VJ+iRyopKoIirxw/rsKraQlQIQ1btffSMMzE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=L6qqQpC5BsGxk1RI7OzB9+s9ZqR01KjjIlIqf8keqN2gy7QdM4Kcis2lsgTXaFxpK4rWU3FeCw+B7i8dX7kWWhPVniS2/iYPeSytgQxsqsY5fw2Ha2dnkumin+B2KMnVejfFR7tXFMRKCrtsnhKArKTnDGUEhVPPEtdjkuLD/Mc= 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=C+im4jjg; 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="C+im4jjg" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 0917C1A1C1B; Thu, 20 Nov 2025 09:12:17 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id D11F36068C; Thu, 20 Nov 2025 09:12:16 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 95A2E10371C0C; Thu, 20 Nov 2025 10:12:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763629935; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=uxcBfrkPXkUZDJCua6/YvADKTChGewQXWcqnNL7MEe0=; b=C+im4jjg3s4gjlZQflMBdfIKdiE2eIvkG3e4496ZqMHij4t43WW4ugrXCTL8ps7n1USQyE 4/y3sc4WK2LLK5UCcr6jR73eMaOyY5gDMGEbn5q09vbxKc8S2vPb+NuVJTFPwfjlsQjlZV SNiJj6j5wG3GGRe8K0DydqmTNGvCRtIUGACoLltTTApNjWB1OHSveUVEhhI8O8aHScuUH0 dm1l7LSz/RHz5mLqbMG5yh7QNDgJWnY/t/EUHpu9Jrw9ZRvdpedR3OliqnY1n0thmGrcbq 6GlAt9FOZoaIMU0FtsjtxBu8KEusRYSIE7VKEfs7r3gd2IAo63v9/9isSgOM8A== From: "Bastien Curutchet (Schneider Electric)" Date: Thu, 20 Nov 2025 10:12:02 +0100 Subject: [PATCH net v6 3/5] net: dsa: microchip: Don't free uninitialized ksz_irq 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: <20251120-ksz-fix-v6-3-891f80ae7f8f@bootlin.com> References: <20251120-ksz-fix-v6-0-891f80ae7f8f@bootlin.com> In-Reply-To: <20251120-ksz-fix-v6-0-891f80ae7f8f@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)" , stable@vger.kernel.org X-Mailer: b4 0.14.2 X-Last-TLS-Session-Version: TLSv1.3 If something goes wrong at setup, 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. Use dsa_switch_for_each_user_port_continue_reverse() in the error path to iterate only over the fully initialized ports. Cc: stable@vger.kernel.org Fixes: cc13ab18b201 ("net: dsa: microchip: ptp: enable interrupt for timest= amping") Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index b17d29dda612ce00ce2e52fbe16c54bd6516c417..49827ac770e6fcc9e4a1a11e881= 4cdd90b17473e 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -3080,7 +3080,7 @@ static int ksz_setup(struct dsa_switch *ds) ksz_ptp_irq_free(ds, dp->index); out_pirq: if (dev->irq > 0) - dsa_switch_for_each_user_port(dp, dev->ds) + dsa_switch_for_each_user_port_continue_reverse(dp, dev->ds) ksz_irq_free(&dev->ports[dp->index].pirq); out_girq: if (dev->irq > 0) --=20 2.51.1