From nobody Tue Dec 2 03:00:10 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 211272D3A6A for ; Mon, 17 Nov 2025 13:06:08 +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=1763384771; cv=none; b=t5dfx9PZI12t4+fEkUeVttVgOb8rlQu82UtwH4e7w3VL95j8ddWsB6Jpxbc4C8lMP91heQ/MaiviPi5UGdXsJ88Lp0P63a51sFFmeegXeQyn2nBADDxwXDGkcXN3G1w/OF3mlB5DAip8yh7oLk1UwpTa8QnAlsa0dCx5P09GShg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763384771; c=relaxed/simple; bh=4r/7XxgCCqAeVsQLUFOd77vszd2iOYLjLQs4R+5In7c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ert0+YybnbRAuudprZZ5xNncj1ZUdnfby1Scn3l6B3cidjFs5dIiyQ6n12uobhM72mF5UlSr/iRtJWRjTEGys+hZVXHANxErydjaEmzEyqI1iu7zU7kAsGWfJHZ+BhB/2CPGGbZTssXBfrQuMnDaid9yMcLZyWH9OazTwA4FDRM= 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=dHBg8iqv; 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="dHBg8iqv" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 0F74A1A1B77; Mon, 17 Nov 2025 13:06:07 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id CE30E606B9; Mon, 17 Nov 2025 13:06:06 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B88D610371D37; Mon, 17 Nov 2025 14:06:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763384766; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=iJC44dVU5yEb8hqqRuBXRUyct/KJL5rrWwNwUJgQGhI=; b=dHBg8iqvDHYQS1AKjR9b5BSpE+mKD/cMAuCDVAOVnaWgR8sFSlHLlBk+gj52vPJDT4LwvR 1xDBTQULp/QL1x8XsKvoSlvUU91IVn9vR/YytMIY++zqDeLAq1c8qFWzWrBkOHpyhViDez tAAkhPg5WPaqb4xYEfuTxgjsSOzPtKTVe1Hi5mI/YNR34xMTRS2AQ1oI6aShlxKmlbXCIh wfch72+0A8XuLLuqpFxTKIYrXcICBZ+ATDZ+doRR3iguKRQ92pcU9w/ttDSgPz2WFHlux9 Bk90WTR4jC+L3mgoyJe93mS+s6fUvtqPueqyEav6SbfMq1kWFXMXXmQh2Re1Bg== From: "Bastien Curutchet (Schneider Electric)" Date: Mon, 17 Nov 2025 14:05:44 +0100 Subject: [PATCH net v4 3/5] 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: <20251117-ksz-fix-v4-3-13e1da58a492@bootlin.com> References: <20251117-ksz-fix-v4-0-13e1da58a492@bootlin.com> In-Reply-To: <20251117-ksz-fix-v4-0-13e1da58a492@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 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. Ensure that the ksz_irq is initialized before calling ksz_irq_free(). 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 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index c724f5af5d98bf3ff784e36393dd5b3fa7b37c13..a622416d966330187ee062b2f44= 051ddf4ce2a78 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -3078,9 +3078,12 @@ static int ksz_setup(struct dsa_switch *ds) dsa_switch_for_each_user_port(dp, dev->ds) ksz_ptp_irq_free(ds, dp->index); out_pirq: - if (dev->irq > 0) - dsa_switch_for_each_user_port(dp, dev->ds) - ksz_irq_free(&dev->ports[dp->index].pirq); + if (dev->irq > 0) { + dsa_switch_for_each_user_port(dp, dev->ds) { + if (dev->ports[dp->index].pirq.domain) + ksz_irq_free(&dev->ports[dp->index].pirq); + } + } out_girq: if (dev->irq > 0) ksz_irq_free(&dev->girq); --=20 2.51.1