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 5115931E0E6 for ; Mon, 17 Nov 2025 08:58:22 +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=1763369907; cv=none; b=jMe37r+MhmgmvwfpWayHjPhjnvuYnzINAf0JtJ8YIwJcDnBWJ679ehP6X/rnscc2Cyzq41m4fx9/xIoH+anSpSbmcqeZYzTPauuLkq1d4PVg1LQCW/hIz9GR/Xx+54qF/kxRJi3aCyBbmJi4xBZeaoeiQJIzZerUOEL1wnWwNdU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763369907; c=relaxed/simple; bh=8Z6d1ejx0Uj/IrkRl7yBKSEwL+DAa0E6NOlwx0oQ3LA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=eK6hq33zRKbwTJYGAtDSzfk/EnZblNh13l0F2m0EgZ3ZQ8VlBDcjUrwMV5Ag7PgQ1uDsuIlJTuyU+//uWwA3flJ4iBuMldj+gELpJvJTWQNxd4PSHmcL6ZjWmBd0ZXyNTI3bVKxQ6KyRMMAxmdNdj6Aui2uoic6oGIzVSSAfshY= 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=Zr7QG6p2; 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="Zr7QG6p2" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 7C33C4E41723; Mon, 17 Nov 2025 08:51:56 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 4F743606B9; Mon, 17 Nov 2025 08:51:56 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id A77E910371D05; Mon, 17 Nov 2025 09:51:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763369515; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:content-language:in-reply-to:references; bh=QY1oVustpLjb4kKFlpFbNvuK8JxAlKLUqgiQYWDRY+w=; b=Zr7QG6p2SPrrbofu079EyUFbMCnif2UE/TvjsAKm8EewlOgH8M8FOtrgdERiqhZwOly52c tmX4oANKUNzfuIBxDQOGJiyN1vJFBpBVcLBkxGEWJ+yjpdLibzAU4XD5JjBa8a+DqscNzT tEb8HazfE/pG24U1XSqfrNmd8APCInMkEzAw5cOKNazQK0iUUk+W589XxZfLi02s8+OKSL ZWsItmcP0xhUC7KS34vNi7QStbTt40HwVd0Nsniwp3qO8yW0RNBvw7a+6H7n8tvBm0z6po 6p+vXU54Cax1Cl8r910eylu9ki9uxJ7slOIEv+7djZ36fe5e01WnqYsmprXYkQ== Message-ID: Date: Mon, 17 Nov 2025 09:51:50 +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 v3 3/4] net: dsa: microchip: Ensure a ksz_irq is initialized before freeing it To: Andrew Lunn Cc: Woojung Huh , UNGLinuxDriver@microchip.com, Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Arun Ramadoss , Pascal Eberhard , =?UTF-8?Q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20251114-ksz-fix-v3-0-acbb3b9cc32f@bootlin.com> <20251114-ksz-fix-v3-3-acbb3b9cc32f@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 Andrew, On 11/14/25 4:00 PM, Andrew Lunn wrote: > On Fri, Nov 14, 2025 at 08:20:22AM +0100, Bastien Curutchet (Schneider Electric) wrote: >> 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: cc13ab18b201 ("net: dsa: microchip: ptp: enable interrupt for timestamping") >> 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 > > I would say the caller is wrong, not ksz_irq_free(). > > Functions like this come in pairs: ksz_irq_setup() & ksz_irq_free(). > _free() should not be called if _setup() was not successful. > > Please take a look if you can fix the caller. If the change is big, > maybe we need this as a minimal fix for net, but make the bigger > change in net-next? Ok, I'll look at it, I think the change won't be that big. Best regards, Bastien