Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1672765

[PATCH][spi-next] spi: stm32: fix range limit checks on div

From Colin King <colin.king@canonical.com>
Newsgroups linux.kernel
Subject [PATCH][spi-next] spi: stm32: fix range limit checks on div
Date 2017-06-22 17:50 +0200
Message-ID <tVcwO-6Is-17@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


From: Colin Ian King <colin.king@canonical.com>

Currently the check for range limits on div is incorrect and will
never return -EINVAL. Fix this by replacing && with ||

Detected by CoverityScan, CID#1446580 ("Structurally dead code")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/spi/spi-stm32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 0553f61ab3b7..b75909e7b117 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -262,7 +262,7 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 speed_hz)
 	 * no need to check it there.
 	 * However, we need to ensure the following calculations.
 	 */
-	if ((div < SPI_MBR_DIV_MIN) &&
+	if ((div < SPI_MBR_DIV_MIN) ||
 	    (div > SPI_MBR_DIV_MAX))
 		return -EINVAL;
 
-- 
2.11.0

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH][spi-next] spi: stm32: fix range limit checks on div Colin King <colin.king@canonical.com> - 2017-06-22 17:50 +0200
  Re: [PATCH][spi-next] spi: stm32: fix range limit checks on div Amelie DELAUNAY <amelie.delaunay@st.com> - 2017-06-22 18:00 +0200
    Re: [PATCH][spi-next] spi: stm32: fix range limit checks on div Colin Ian King <colin.king@canonical.com> - 2017-06-22 18:00 +0200
    Re: [PATCH][spi-next] spi: stm32: fix range limit checks on div Mark Brown <broonie@kernel.org> - 2017-06-23 13:20 +0200
  Re: [PATCH][spi-next] spi: stm32: fix range limit checks on div Amelie DELAUNAY <amelie.delaunay@st.com> - 2017-06-23 14:50 +0200

csiph-web