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 D56521D5AD3; Tue, 15 Oct 2024 13:13:38 +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=1728998018; cv=none; b=cWFv7E7GStyfmxLJWAGkM2WrYo/7V7QwUAkovDTMnatClWBLPoWK7wCyPT+KZGdvNLlixdJB0AmB7Cd2jDYTpSyIvE/5SgG/5FVcHTsLUMCO/ASd+O0tVRYHqz9G6YLR3W6GBO8DYDysFOSjE/1tV9gN6qd8cZzy0vny+IUvp6A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728998018; c=relaxed/simple; bh=llJE/fevbi1DImn0iV7zjoVL94MHAla5aQwkx9/Da5c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q4fPjvmxuuM1zSU8fjfLGVxTy4Z480GWQ7ncLYpeynBsI9fPegmhKRBDTz2pn+c06/C1DlBOpK+WSysPCw2+jJIV5jYLxF3N4gB/n/2Nphgff0G7qtBE+uf0lVNy32lYDBP/OzjV5+HcY5VRQXIk94nXQ8bR4/xoe++3f9zZqu0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=PXUPI75H; 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="PXUPI75H" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 448F3C4CECF; Tue, 15 Oct 2024 13:13:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728998018; bh=llJE/fevbi1DImn0iV7zjoVL94MHAla5aQwkx9/Da5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PXUPI75HGX5oGXNDbFu9GuuZ5fJqs8TKWteRZixxTnG/C8mJw8wTmfOMWOs4dAu2K H03vUrL00b0q5BN6mI+r2P9KxrSiot0yTq53dUYj9bkv/5EqpIcpYowid1lTTgvfn8 wIe9QUy7n1pG6cUO0dxM5QzBB0fdof67sfI7P4m0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ben Dooks , Andi Shyti , Mark Brown , Sasha Levin Subject: [PATCH 5.10 355/518] spi: s3c64xx: fix timeout counters in flush_fifo Date: Tue, 15 Oct 2024 14:44:19 +0200 Message-ID: <20241015123930.669520396@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241015123916.821186887@linuxfoundation.org> References: <20241015123916.821186887@linuxfoundation.org> User-Agent: quilt/0.67 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 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ben Dooks [ Upstream commit 68a16708d2503b6303d67abd43801e2ca40c208d ] In the s3c64xx_flush_fifo() code, the loops counter is post-decremented in the do { } while(test && loops--) condition. This means the loops is left at the unsigned equivalent of -1 if the loop times out. The test after will never pass as if tests for loops == 0. Signed-off-by: Ben Dooks Fixes: 230d42d422e7 ("spi: Add s3c64xx SPI Controller driver") Reviewed-by: Andi Shyti Link: https://patch.msgid.link/20240924134009.116247-2-ben.dooks@codethink.co.uk Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-s3c64xx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index d435df1b715bb..7beea6f930933 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -215,7 +215,7 @@ static void s3c64xx_flush_fifo(struct s3c64xx_spi_driver_data *sdd) loops = msecs_to_loops(1); do { val = readl(regs + S3C64XX_SPI_STATUS); - } while (TX_FIFO_LVL(val, sdd) && loops--); + } while (TX_FIFO_LVL(val, sdd) && --loops); if (loops == 0) dev_warn(&sdd->pdev->dev, "Timed out flushing TX FIFO\n"); @@ -228,7 +228,7 @@ static void s3c64xx_flush_fifo(struct s3c64xx_spi_driver_data *sdd) readl(regs + S3C64XX_SPI_RX_DATA); else break; - } while (loops--); + } while (--loops); if (loops == 0) dev_warn(&sdd->pdev->dev, "Timed out flushing RX FIFO\n"); -- 2.43.0