Skip to contentSkip to conversation

spi: spi-zynqmp-gqspi: unlock on error path in exec_op

PATCH In review Dan Carpenter 3 participants 3 messages Apr 13, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: spi-zynqmp-gqspi: unlock on error path in exec_op

If the allocation fails then we need to drop the &xqspi->op_lock mutex before returning.

Fixes a0f65be6e880 ("spi: spi-zynqmp-gqspi: add mutex locking for exec_op")
---
 drivers/spi/spi-zynqmp-gqspi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/spi/spi-zynqmp-gqspi.c +4 -2
index 9494da9aea40..d08ca6d5670c 100644
@@ -965,8 +965,10 @@ static int zynqmp_qspi_exec_op(struct spi_mem *mem,
 
 	if (op->cmd.opcode) {
 		tmpbuf = kzalloc(op->cmd.nbytes, GFP_KERNEL | GFP_DMA);
-		if (!tmpbuf)
-			return -ENOMEM;
+		if (!tmpbuf) {
+			err = -ENOMEM;
+			goto return_err;
+		}
 		tmpbuf[0] = op->cmd.opcode;
 		reinit_completion(&xqspi->data_completion);
 		xqspi->txbuf = tmpbuf;
Signature · 1 line
2.30.2
maintainer
#1 lore raw
Quoted 2 lines · Dan Carpenter

If the allocation fails then we need to drop the &xqspi->op_lock mutex before returning.

This doesn't apply against current code, please check and resend.

#2 lore raw
In reply to Dan Carpenter

Hi Dan,

Quoted 16 lines · Dan Carpenter

If the allocation fails then we need to drop the &xqspi->op_lock mutex before returning.

Fixes a0f65be6e880 ("spi: spi-zynqmp-gqspi: add mutex locking for exec_op")
---
  drivers/spi/spi-zynqmp-gqspi.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
drivers/spi/spi-zynqmp-gqspi.c +0 -0
index 9494da9aea40..d08ca6d5670c 100644
@@ -965,8 +965,10 @@ static int zynqmp_qspi_exec_op(struct spi_mem *mem,
 
  	if (op->cmd.opcode) {

drivers/spi/spi-zynqmp-gqspi.c static int zynqmp_qspi_exec_op(struct spi_mem *mem, · line 974

Quoted 10 lines
drivers/spi/spi-zynqmp-gqspi.c +4 -2
  		tmpbuf = kzalloc(op->cmd.nbytes, GFP_KERNEL | GFP_DMA);
-		if (!tmpbuf)
-			return -ENOMEM;
+		if (!tmpbuf) {
+			err = -ENOMEM;
+			goto return_err;
+		}
  		tmpbuf[0] = op->cmd.opcode;
  		reinit_completion(&xqspi->data_completion);
  		xqspi->txbuf = tmpbuf;

Thank you for your patch. But similar patch has been applied:

https://www.spinics.net/lists/arm-kernel/msg888807.html

Thanks,

Quanyang