From mboxrd@z Thu Jan 1 00:00:00 1970 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 732E6304BB7 for ; Mon, 17 Nov 2025 18:52:01 +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=1763405525; cv=none; b=WTnEXa0xzQcr2+LduwB2J7gU4Bv//ovc8qVUE7llM2UjQ8jKZ7ZFZeMYwbI7dQ9GWVgxM1c9gfFoHxYx6eougJxabzbyq833CRcLTKP+roaaglybtPKdzCZEF1HfXyidCzX/hPkINAcdLl7vjgkyOLM7KkuuTxAuBUaAxilQlro= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763405525; c=relaxed/simple; bh=N0zzGvB4gmHXQPUV/DvfUAPgtp1mAqHxxP4vQDVL390=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Y09Qw6hNN6RhFoA1aTyaT1zLTF3yInECRhOvoMz1Ik7o6UopeG49vw4aD+z4W10tXb/prpFgSKsiVT8p5taGXdppYVHKRu4qBXN40GxpC9kKriehRRQv07g3Bp90wFZuQGnl3bxgWcmjynEZjM0KCDvdrNLD/ws6GUWttFADlxk= 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=hS514xmb; 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="hS514xmb" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id BC3014E41735; Mon, 17 Nov 2025 18:51:59 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 90C70606B9; Mon, 17 Nov 2025 18:51:59 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 4549B10371413; Mon, 17 Nov 2025 19:51:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763405518; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:content-language:in-reply-to:references; bh=t/mcnN4+ND5npEnAXQxOQIc+lsltG5KMC8Z93nq3lYM=; b=hS514xmbsxkDamrwJz8tZhCR0g0yUTwBbMZj6/rGOgycqbpS6WOz1Kq/lHrKsmDX4I8Kth S8hVW9yN+GTej7ppCIPJAUH6yfy4j5t4aICMEtWLvXw2+ta/Yo8J+uvxWfJHqC6basJpNv r+Upr/YzyGTucqQuwJ8KXR3iEDuzg1GRtPMAADc6gn+NxnrECZ+z9LDjvFhBpXfoEEBpKW pddG6JdfhA2qcJrw6MaJHFXDy0+IKrFIVkJYwLdAauERhYLNYOynJSoeDQlaGZN0cJiEeV ng5H+wAZyw+zgR7RGlYJYYmDCCOb9q9dVjNmsaf6hj4k75UYp2+lj8pRSqdW0A== Message-ID: Date: Mon, 17 Nov 2025 19:51:52 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net v4 4/5] net: dsa: microchip: Free previously initialized ports on init failures To: Maxime Chevallier , 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 References: <20251117-ksz-fix-v4-0-13e1da58a492@bootlin.com> <20251117-ksz-fix-v4-4-13e1da58a492@bootlin.com> From: Bastien Curutchet Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Last-TLS-Session-Version: TLSv1.3 Hi Maxime, On 11/17/25 5:28 PM, Maxime Chevallier wrote: > Hi Bastien, > > On 17/11/2025 14:05, Bastien Curutchet (Schneider Electric) wrote: >> If ksz_pirq_setup() fails after at least one successful port >> initialization, the goto jumps directly to the global irq freeing, >> leaking the resources of the previously initialized ports. >> >> Fix the goto jump to release all the potentially initialized ports. >> Remove the no-longer used out_girq label. >> >> Fixes: c9cd961c0d43 ("net: dsa: microchip: lan937x: add interrupt support for port phy link") >> Signed-off-by: Bastien Curutchet (Schneider Electric) >> --- >> drivers/net/dsa/microchip/ksz_common.c | 6 ++---- >> 1 file changed, 2 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c >> index a622416d966330187ee062b2f44051ddf4ce2a78..2b6f7abea00776fafff0c1774cab297a7ef261da 100644 >> --- a/drivers/net/dsa/microchip/ksz_common.c >> +++ b/drivers/net/dsa/microchip/ksz_common.c >> @@ -3035,7 +3035,7 @@ static int ksz_setup(struct dsa_switch *ds) >> dsa_switch_for_each_user_port(dp, dev->ds) { >> ret = ksz_pirq_setup(dev, dp->index); >> if (ret) >> - goto out_girq; >> + goto out_pirq; >> >> if (dev->info->ptp_capable) { >> ret = ksz_ptp_irq_setup(ds, dp->index); >> @@ -3083,10 +3083,8 @@ static int ksz_setup(struct dsa_switch *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); >> + } >> >> return ret; >> } >> > > Looking at the code, I think it's still not enough, but feel free > to correct me. > > In ksz_setup(), in one single loop we do : > > dsa_switch_for_each_user_port(dp, dev->ds) { > ksz_pirq_setup(); > > ksz_ptp_irq_setup(); > } > > However when anything fails in the above loop, we jump straight > to out_pirq, which doesn't clean the ptpirq :( Good catch, I should also merge together the out_ptpirq and out_pirq labels then. And ensure that the PTP IRQ is initialized before freeing it. I'll respin with that. Best regards, Bastien