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 497FF171671; Mon, 14 Oct 2024 15:18:24 +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=1728919104; cv=none; b=WGAeMNZwxeRyxy8PbjW2+1zJ+lTcDzPafSBz7UCg8h9ncthaarIXZPlxEzGGt661TElE7gNGaIDIC2bVOQjoPaZh/HBA+pRwwUrES0UMvUITyMN6s8lCwMbgpu1VK/7cizKVZaZW8c4lwa9XizAC6sBNFo+j2mFY0ARkB6/a7So= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728919104; c=relaxed/simple; bh=C2nFJhDVqVOkmEGKzP6dStzzUtObAlqe+97RPx6WrUE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tza/4Rvo88nuJcltmQX3Sx0mgLmnrhtAH9HxDrpxOFgc6aAiDFpztuUIF2gM0lV0TaPPtJsOwpAQWyIzAnYBEx6N5JbbJDwGvKYR1yZaIBB+H989KWK0enUu4ariulhDBvN3cHwO8Mg5kuKGtgIKhqsQBAkkr2MgBQP2QWD8M0s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=m8NR7hpF; 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="m8NR7hpF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AEF0EC4CEC3; Mon, 14 Oct 2024 15:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728919104; bh=C2nFJhDVqVOkmEGKzP6dStzzUtObAlqe+97RPx6WrUE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m8NR7hpFq8QzTp4ZIyMxShbTfdx9lUXSziWY2pmm28ARnBdAHfi5FREaKS5DjCrhg i7LESRufpSG1ibv/sd4wnlQ3kPMHqqfEQT4Q5B7mJGgKGxv1JZQ0Im9fk91GiGUahH h5sqBUMrStr5DIPRjPT9lAi9HH9VL5sYGrL+2fjI= 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 6.1 514/798] spi: s3c64xx: fix timeout counters in flush_fifo Date: Mon, 14 Oct 2024 16:17:48 +0200 Message-ID: <20241014141238.174927546@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241014141217.941104064@linuxfoundation.org> References: <20241014141217.941104064@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-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 1480df7b43b3f..c481f80b4d8d2 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -219,7 +219,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"); @@ -232,7 +232,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