diff mbox series

spi: spi-geni-qcom: fix error handling in spi_geni_grab_gpi_chan()

Message ID 20211110073935.GA5176@kili (mailing list archive)
State Accepted
Commit 6532582c353f4c83e3ccdd7255020ab852b90b0b
Headers show
Series spi: spi-geni-qcom: fix error handling in spi_geni_grab_gpi_chan() | expand

Commit Message

Dan Carpenter Nov. 10, 2021, 7:39 a.m. UTC
This code has several issues:
1) It passes IS_ERR() to dev_err_probe() instead of PTR_ERR().
2) It always prints an error message, even when it succeeds.
3) The "if (ret < 0) {" conditions are never true.
4) If requesting "mas->tx" fails then it sets "mas->rx" to NULL but the
   intention was to set "mas->tx" to NULL.

Fixes: b59c122484ec ("spi: spi-geni-qcom: Add support for GPI dma")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/spi/spi-geni-qcom.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

Comments

Vinod Koul Nov. 10, 2021, 12:07 p.m. UTC | #1
On 10-11-21, 10:39, Dan Carpenter wrote:
> This code has several issues:
> 1) It passes IS_ERR() to dev_err_probe() instead of PTR_ERR().
> 2) It always prints an error message, even when it succeeds.
> 3) The "if (ret < 0) {" conditions are never true.
> 4) If requesting "mas->tx" fails then it sets "mas->rx" to NULL but the
>    intention was to set "mas->tx" to NULL.

Acked-By: Vinod Koul <vkoul@kernel.org>
Mark Brown Nov. 12, 2021, 9:27 p.m. UTC | #2
On Wed, 10 Nov 2021 10:39:35 +0300, Dan Carpenter wrote:
> This code has several issues:
> 1) It passes IS_ERR() to dev_err_probe() instead of PTR_ERR().
> 2) It always prints an error message, even when it succeeds.
> 3) The "if (ret < 0) {" conditions are never true.
> 4) If requesting "mas->tx" fails then it sets "mas->rx" to NULL but the
>    intention was to set "mas->tx" to NULL.
> 
> [...]

Applied to

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

Thanks!

[1/1] spi: spi-geni-qcom: fix error handling in spi_geni_grab_gpi_chan()
      commit: 6532582c353f4c83e3ccdd7255020ab852b90b0b

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-geni-qcom.c b/drivers/spi/spi-geni-qcom.c
index 27a446faf143..e2affaee4e76 100644
--- a/drivers/spi/spi-geni-qcom.c
+++ b/drivers/spi/spi-geni-qcom.c
@@ -491,22 +491,26 @@  static int spi_geni_grab_gpi_chan(struct spi_geni_master *mas)
 	int ret;
 
 	mas->tx = dma_request_chan(mas->dev, "tx");
-	ret = dev_err_probe(mas->dev, IS_ERR(mas->tx), "Failed to get tx DMA ch\n");
-	if (ret < 0)
+	if (IS_ERR(mas->tx)) {
+		ret = dev_err_probe(mas->dev, PTR_ERR(mas->tx),
+				    "Failed to get tx DMA ch\n");
 		goto err_tx;
+	}
 
 	mas->rx = dma_request_chan(mas->dev, "rx");
-	ret = dev_err_probe(mas->dev, IS_ERR(mas->rx), "Failed to get rx DMA ch\n");
-	if (ret < 0)
+	if (IS_ERR(mas->rx)) {
+		ret = dev_err_probe(mas->dev, PTR_ERR(mas->rx),
+				    "Failed to get rx DMA ch\n");
 		goto err_rx;
+	}
 
 	return 0;
 
 err_rx:
+	mas->rx = NULL;
 	dma_release_channel(mas->tx);
-	mas->tx = NULL;
 err_tx:
-	mas->rx = NULL;
+	mas->tx = NULL;
 	return ret;
 }