diff mbox series

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

Message ID YHV3gkc3RFcBZVAK@mwanda (mailing list archive)
State New, archived
Headers show
Series spi: spi-zynqmp-gqspi: unlock on error path in exec_op | expand

Commit Message

Dan Carpenter April 13, 2021, 10:50 a.m. UTC
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")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/spi/spi-zynqmp-gqspi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Mark Brown April 13, 2021, 11:35 a.m. UTC | #1
On Tue, Apr 13, 2021 at 01:50:42PM +0300, Dan Carpenter wrote:
> 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.
Quanyang Wang April 13, 2021, 11:44 a.m. UTC | #2
Hi Dan,

On 4/13/21 6:50 PM, Dan Carpenter wrote:
> 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>   drivers/spi/spi-zynqmp-gqspi.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c
> index 9494da9aea40..d08ca6d5670c 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)
> -			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
diff mbox series

Patch

diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c
index 9494da9aea40..d08ca6d5670c 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)
-			return -ENOMEM;
+		if (!tmpbuf) {
+			err = -ENOMEM;
+			goto return_err;
+		}
 		tmpbuf[0] = op->cmd.opcode;
 		reinit_completion(&xqspi->data_completion);
 		xqspi->txbuf = tmpbuf;