From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 34F8515198D; Wed, 5 Feb 2025 14:03:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738764217; cv=none; b=VOO7OI5FNK4+uGza8ZKlSMl10HbZf7nt2GVRrYgEvIBTd+2IcXki5Y20KtZ4WRSmqHgWi6TTuVszacnQ3WKeSNxtyLCwkxJDK06FqAav6BmerMw7tFTtIvPR3lbf5cFX3aZ5uOBuRnYI2dI2hdH1iBFsCykmGf4MHWg+OHYKoPc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738764217; c=relaxed/simple; bh=QKCyNgU1tXjpw5eQbpgjcNIijBVi/C4ro1xHKmw+Bew=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PmIGkNpHfdH9L6q3TqNPqIwQr94pKny7+AzTJ+cUxPn8jtNZNEm8nrjRoQBUkIhdqEsw8KOYa7NJKl36Ss8sgpYeryUpy7aPYuxotvydeLnkIGiV5IICxLBJYjOiHB7yBQpKPSqPlp119BAWUJz0Ij0tzuN7eQ1JphDC54IImJs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=2X31SRRZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="2X31SRRZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96AC4C4CED1; Wed, 5 Feb 2025 14:03:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738764217; bh=QKCyNgU1tXjpw5eQbpgjcNIijBVi/C4ro1xHKmw+Bew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2X31SRRZeCyUh09uL+Fyoas0xk6roaFNHIjSgzNbGB8oM4y6RNcXy76KC03cIVM3X o4qcv5H8lKk1X0N0cgmFuPEQ0yXmqsKyTowLz4JSgeS7VgRYR9DEHqd8U5FcLiiJ9g oreDdcqYc7sOoVXpqKW+0RWgaCb3yL5wxaFUWd5g= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Roger Quadros , Simon Horman , Siddharth Vadapalli , Jacob Keller , "David S. Miller" , Sasha Levin Subject: [PATCH 6.6 150/393] net: ethernet: ti: am65-cpsw: fix freeing IRQ in am65_cpsw_nuss_remove_tx_chns() Date: Wed, 5 Feb 2025 14:41:09 +0100 Message-ID: <20250205134426.041317061@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250205134420.279368572@linuxfoundation.org> References: <20250205134420.279368572@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Roger Quadros [ Upstream commit 4395a44acb15850e492dd1de9ec4b6479d96bc80 ] When getting the IRQ we use k3_udma_glue_tx_get_irq() which returns negative error value on error. So not NULL check is not sufficient to deteremine if IRQ is valid. Check that IRQ is greater then zero to ensure it is valid. There is no issue at probe time but at runtime user can invoke .set_channels which results in the following call chain. am65_cpsw_set_channels() am65_cpsw_nuss_update_tx_rx_chns() am65_cpsw_nuss_remove_tx_chns() am65_cpsw_nuss_init_tx_chns() At this point if am65_cpsw_nuss_init_tx_chns() fails due to k3_udma_glue_tx_get_irq() then tx_chn->irq will be set to a negative value. Then, at subsequent .set_channels with higher channel count we will attempt to free an invalid IRQ in am65_cpsw_nuss_remove_tx_chns() leading to a kernel warning. The issue is present in the original commit that introduced this driver, although there, am65_cpsw_nuss_update_tx_rx_chns() existed as am65_cpsw_nuss_update_tx_chns(). Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver") Signed-off-by: Roger Quadros Reviewed-by: Simon Horman Reviewed-by: Siddharth Vadapalli Reviewed-by: Jacob Keller Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index d556e705ec000..8ffc1fbb036f9 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -1651,7 +1651,7 @@ void am65_cpsw_nuss_remove_tx_chns(struct am65_cpsw_common *common) for (i = 0; i < common->tx_ch_num; i++) { struct am65_cpsw_tx_chn *tx_chn = &common->tx_chns[i]; - if (tx_chn->irq) + if (tx_chn->irq > 0) devm_free_irq(dev, tx_chn->irq, tx_chn); netif_napi_del(&tx_chn->napi_tx); -- 2.39.5