Skip to contentSkip to conversation

Patch "spi: spi-cadence-quadspi: Fix division by zero warning" has been added to the 5.13-stable tree

DISCUSSION Yoshitaka Ikeda 1 participant 1 message Jul 26, 2021 1 message not in the archive Stable branch

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi,

This patch is not up to date.

The following revert and commit are the latest.
https://patchwork.kernel.org/project/spi-devel-general/patch/[email protected]/
https://patchwork.kernel.org/project/spi-devel-general/patch/[email protected]/

Please replace it with the latest patch.

Best Regards,

Quoted 62 lines · Sasha Levin

This is a note to let you know that I've just added the patch titled

spi: spi-cadence-quadspi: Fix division by zero warning

to the 5.13-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
spi-spi-cadence-quadspi-fix-division-by-zero-warning.patch
and it can be found in the queue-5.13 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

commit 8e7f9650f5d883bca7b0239529c1b704673abd38

Author: Yoshitaka Ikeda <[email protected]>
Date:   Thu Jul 15 16:21:32 2021 +0000

spi: spi-cadence-quadspi: Fix division by zero warning

[ Upstream commit 55cef88bbf12f3bfbe5c2379a8868a034707e755 ]

Fix below division by zero warning:
- Added an if statement because buswidth can be zero, resulting in division by zero.
- The modified code was based on another driver (atmel-quadspi).

[ 0.795337] Division by zero in kernel.
:
[ 0.834051] [<807fd40c>] (__div0) from [<804e1acc>] (Ldiv0+0x8/0x10)
[ 0.839097] [<805f0710>] (cqspi_exec_mem_op) from [<805edb4c>] (spi_mem_exec_op+0x3b0/0x3f8)

Fixes 7512eaf54190 ("spi: cadence-quadspi: Fix dummy cycle calculation when buswidth > 1")
drivers/spi/spi-cadence-quadspi.c +6 -4
index 7a00346ff9b9..13d1f0ce618e 100644
@@ -307,11 +307,13 @@ static unsigned int cqspi_calc_rdreg(struct cqspi_flash_pdata *f_pdata)
 
 static unsigned int cqspi_calc_dummy(const struct spi_mem_op *op, bool dtr)
 {
-	unsigned int dummy_clk;
+	unsigned int dummy_clk = 0;
 
-	dummy_clk = op->dummy.nbytes * (8 / op->dummy.buswidth);
-	if (dtr)
-		dummy_clk /= 2;
+	if (op->dummy.buswidth && op->dummy.nbytes) {
+		dummy_clk = op->dummy.nbytes * (8 / op->dummy.buswidth);
+		if (dtr)
+			dummy_clk /= 2;
+	}
 
 	return dummy_clk;
 }