* [PATCH] spi: spi-geni-qcom: fix error handling in spi_geni_grab_gpi_chan()
@ 2021-11-10 7:39 Dan Carpenter
2021-11-10 12:07 ` Vinod Koul
2021-11-12 21:27 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-11-10 7:39 UTC (permalink / raw)
To: Andy Gross, Vinod Koul
Cc: Bjorn Andersson, Mark Brown, linux-spi, kernel-janitors
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(-)
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;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] spi: spi-geni-qcom: fix error handling in spi_geni_grab_gpi_chan()
2021-11-10 7:39 [PATCH] spi: spi-geni-qcom: fix error handling in spi_geni_grab_gpi_chan() Dan Carpenter
@ 2021-11-10 12:07 ` Vinod Koul
2021-11-12 21:27 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2021-11-10 12:07 UTC (permalink / raw)
To: Dan Carpenter
Cc: Andy Gross, Bjorn Andersson, Mark Brown, linux-spi, kernel-janitors
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>
--
~Vinod
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] spi: spi-geni-qcom: fix error handling in spi_geni_grab_gpi_chan()
2021-11-10 7:39 [PATCH] spi: spi-geni-qcom: fix error handling in spi_geni_grab_gpi_chan() Dan Carpenter
2021-11-10 12:07 ` Vinod Koul
@ 2021-11-12 21:27 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2021-11-12 21:27 UTC (permalink / raw)
To: Andy Gross, Dan Carpenter, Vinod Koul
Cc: kernel-janitors, linux-spi, Bjorn Andersson
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-12 21:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-10 7:39 [PATCH] spi: spi-geni-qcom: fix error handling in spi_geni_grab_gpi_chan() Dan Carpenter
2021-11-10 12:07 ` Vinod Koul
2021-11-12 21:27 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).