Linux-SPI Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] spi: spi-zynqmp-gqspi: unlock on error path in exec_op
@ 2021-04-13 10:50 Dan Carpenter
  2021-04-13 11:35 ` Mark Brown
  2021-04-13 11:44 ` quanyang.wang
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-04-13 10:50 UTC (permalink / raw)
  To: Mark Brown, Quanyang Wang
  Cc: Michal Simek, Amit Kumar Mahapatra, linux-spi, kernel-janitors

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;
-- 
2.30.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] spi: spi-zynqmp-gqspi: unlock on error path in exec_op
  2021-04-13 10:50 [PATCH] spi: spi-zynqmp-gqspi: unlock on error path in exec_op Dan Carpenter
@ 2021-04-13 11:35 ` Mark Brown
  2021-04-13 11:44 ` quanyang.wang
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2021-04-13 11:35 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Quanyang Wang, Michal Simek, Amit Kumar Mahapatra, linux-spi,
	kernel-janitors


[-- Attachment #1: Type: text/plain, Size: 223 bytes --]

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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] spi: spi-zynqmp-gqspi: unlock on error path in exec_op
  2021-04-13 10:50 [PATCH] spi: spi-zynqmp-gqspi: unlock on error path in exec_op Dan Carpenter
  2021-04-13 11:35 ` Mark Brown
@ 2021-04-13 11:44 ` quanyang.wang
  1 sibling, 0 replies; 3+ messages in thread
From: quanyang.wang @ 2021-04-13 11:44 UTC (permalink / raw)
  To: Dan Carpenter, Mark Brown
  Cc: Michal Simek, Amit Kumar Mahapatra, linux-spi, kernel-janitors

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-13 10:50 [PATCH] spi: spi-zynqmp-gqspi: unlock on error path in exec_op Dan Carpenter
2021-04-13 11:35 ` Mark Brown
2021-04-13 11:44 ` quanyang.wang

Linux-SPI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-spi/0 linux-spi/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-spi linux-spi/ https://lore.kernel.org/linux-spi \
		linux-spi@vger.kernel.org
	public-inbox-index linux-spi

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-spi


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git