[PATCH 5.10 255/530] spi: spi-zynqmp-gqspi: Fix missing unlock on error in zynqmp_qspi_exec_op()
From: Greg Kroah-Hartman
Date: Wed May 12 2021 - 12:00:36 EST
From: Wei Yongjun <weiyongjun1@xxxxxxxxxx>
[ Upstream commit 6043357263fbe2df0bf0736d971ad5dce7d19dc1 ]
Add the missing unlock before return from function zynqmp_qspi_exec_op()
in the error handling case.
Fixes: a0f65be6e880 ("spi: spi-zynqmp-gqspi: add mutex locking for exec_op")
Reported-by: Hulk Robot <hulkci@xxxxxxxxxx>
Signed-off-by: Wei Yongjun <weiyongjun1@xxxxxxxxxx>
Link: https://lore.kernel.org/r/20210412160025.194171-1-weiyongjun1@xxxxxxxxxx
Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
drivers/spi/spi-zynqmp-gqspi.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c
index 036d8ae41c06..408e348382c5 100644
--- a/drivers/spi/spi-zynqmp-gqspi.c
+++ b/drivers/spi/spi-zynqmp-gqspi.c
@@ -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)
+ if (!tmpbuf) {
+ mutex_unlock(&xqspi->op_lock);
return -ENOMEM;
+ }
tmpbuf[0] = op->cmd.opcode;
reinit_completion(&xqspi->data_completion);
xqspi->txbuf = tmpbuf;
--
2.30.2