diff mbox series

spi: aspeed: Fix an error handling path in aspeed_spi_[read|write]_user()

Message ID 4052aa2f9a9ea342fa6af83fa991b55ce5d5819e.1732051814.git.christophe.jaillet@wanadoo.fr
State Accepted
Commit c84dda3751e945a67d71cbe3af4474aad24a5794
Headers show
Series spi: aspeed: Fix an error handling path in aspeed_spi_[read|write]_user() | expand

Commit Message

Christophe JAILLET Nov. 19, 2024, 9:30 p.m. UTC
A aspeed_spi_start_user() is not balanced by a corresponding
aspeed_spi_stop_user().
Add the missing call.

Fixes: e3228ed92893 ("spi: spi-mem: Convert Aspeed SMC driver to spi-mem")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only.


This patch is completely speculative, review with care!

It is only based on naming where a _start() function if not followed by a
_stop() in some paths but is in other paths.
---
 drivers/spi/spi-aspeed-smc.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Chin-Ting Kuo Nov. 20, 2024, 2:08 a.m. UTC | #1
Hi Christophe,

Thanks for the patch.

> -----Original Message-----
> From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> Sent: Wednesday, November 20, 2024 5:30 AM
> Subject: [PATCH] spi: aspeed: Fix an error handling path in
> aspeed_spi_[read|write]_user()
> 
> A aspeed_spi_start_user() is not balanced by a corresponding
> aspeed_spi_stop_user().
> Add the missing call.
> 
> Fixes: e3228ed92893 ("spi: spi-mem: Convert Aspeed SMC driver to spi-mem")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Compile tested only.
> 
> 
> This patch is completely speculative, review with care!
> 
> It is only based on naming where a _start() function if not followed by a
> _stop() in some paths but is in other paths.
> ---
>  drivers/spi/spi-aspeed-smc.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c index
> 8eb843ddb25f..e9beae95dded 100644
> --- a/drivers/spi/spi-aspeed-smc.c
> +++ b/drivers/spi/spi-aspeed-smc.c
> @@ -239,7 +239,7 @@ static ssize_t aspeed_spi_read_user(struct
> aspeed_spi_chip *chip,
> 
>  	ret = aspeed_spi_send_cmd_addr(chip, op->addr.nbytes, offset,
> op->cmd.opcode);
>  	if (ret < 0)
> -		return ret;
> +		goto stop_user;
> 
>  	if (op->dummy.buswidth && op->dummy.nbytes) {
>  		for (i = 0; i < op->dummy.nbytes / op->dummy.buswidth; i++) @@
> -249,8 +249,9 @@ static ssize_t aspeed_spi_read_user(struct aspeed_spi_chip
> *chip,
>  	aspeed_spi_set_io_mode(chip, io_mode);
> 
>  	aspeed_spi_read_from_ahb(buf, chip->ahb_base, len);

How about adding a blank line here?

> +stop_user:
>  	aspeed_spi_stop_user(chip);
> -	return 0;
> +	return ret;
>  }
> 
>  static ssize_t aspeed_spi_write_user(struct aspeed_spi_chip *chip, @@
> -261,10 +262,11 @@ static ssize_t aspeed_spi_write_user(struct
> aspeed_spi_chip *chip,
>  	aspeed_spi_start_user(chip);
>  	ret = aspeed_spi_send_cmd_addr(chip, op->addr.nbytes, op->addr.val,
> op->cmd.opcode);
>  	if (ret < 0)
> -		return ret;
> +		goto stop_user;
>  	aspeed_spi_write_to_ahb(chip->ahb_base, op->data.buf.out,
> op->data.nbytes);

A blank line here?

> +stop_user:
>  	aspeed_spi_stop_user(chip);
> -	return 0;
> +	return ret;
>  }
> 
>  /* support for 1-1-1, 1-1-2 or 1-1-4 */
> --
> 2.47.0

Chin-Ting
Mark Brown Dec. 10, 2024, 1 p.m. UTC | #2
On Tue, 19 Nov 2024 22:30:29 +0100, Christophe JAILLET wrote:
> A aspeed_spi_start_user() is not balanced by a corresponding
> aspeed_spi_stop_user().
> Add the missing call.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: aspeed: Fix an error handling path in aspeed_spi_[read|write]_user()
      commit: c84dda3751e945a67d71cbe3af4474aad24a5794

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
diff mbox series

Patch

diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
index 8eb843ddb25f..e9beae95dded 100644
--- a/drivers/spi/spi-aspeed-smc.c
+++ b/drivers/spi/spi-aspeed-smc.c
@@ -239,7 +239,7 @@  static ssize_t aspeed_spi_read_user(struct aspeed_spi_chip *chip,
 
 	ret = aspeed_spi_send_cmd_addr(chip, op->addr.nbytes, offset, op->cmd.opcode);
 	if (ret < 0)
-		return ret;
+		goto stop_user;
 
 	if (op->dummy.buswidth && op->dummy.nbytes) {
 		for (i = 0; i < op->dummy.nbytes / op->dummy.buswidth; i++)
@@ -249,8 +249,9 @@  static ssize_t aspeed_spi_read_user(struct aspeed_spi_chip *chip,
 	aspeed_spi_set_io_mode(chip, io_mode);
 
 	aspeed_spi_read_from_ahb(buf, chip->ahb_base, len);
+stop_user:
 	aspeed_spi_stop_user(chip);
-	return 0;
+	return ret;
 }
 
 static ssize_t aspeed_spi_write_user(struct aspeed_spi_chip *chip,
@@ -261,10 +262,11 @@  static ssize_t aspeed_spi_write_user(struct aspeed_spi_chip *chip,
 	aspeed_spi_start_user(chip);
 	ret = aspeed_spi_send_cmd_addr(chip, op->addr.nbytes, op->addr.val, op->cmd.opcode);
 	if (ret < 0)
-		return ret;
+		goto stop_user;
 	aspeed_spi_write_to_ahb(chip->ahb_base, op->data.buf.out, op->data.nbytes);
+stop_user:
 	aspeed_spi_stop_user(chip);
-	return 0;
+	return ret;
 }
 
 /* support for 1-1-1, 1-1-2 or 1-1-4 */