public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: tegra: Fix failure during probe deferral cleanup
@ 2023-06-08  7:56 Thierry Reding
  2023-06-08  8:39 ` Andi Shyti
  0 siblings, 1 reply; 3+ messages in thread
From: Thierry Reding @ 2023-06-08  7:56 UTC (permalink / raw)
  To: Wolfram Sang, Andi Shyti; +Cc: Jon Hunter, Akhil R, linux-i2c, linux-tegra

From: Thierry Reding <treding@nvidia.com>

If the driver fails to obtain a DMA channel, it will initiate cleanup
and try to release the DMA channel that couldn't be retrieved. This will
cause a crash because the cleanup will try to dereference an ERR_PTR()-
encoded error code.

However, there's nothing to clean up at this point yet, so we can avoid
this by simply propagating the error code.

Fixes: fcc8a89a1c83 ("i2c: tegra: Share same DMA channel for RX and TX")
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/i2c/busses/i2c-tegra.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index f155e9028f94..0eab199900ae 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -458,10 +458,8 @@ static int tegra_i2c_init_dma(struct tegra_i2c_dev *i2c_dev)
 	 * with existing devicetrees.
 	 */
 	i2c_dev->dma_chan = dma_request_chan(i2c_dev->dev, "tx");
-	if (IS_ERR(i2c_dev->dma_chan)) {
-		err = PTR_ERR(i2c_dev->dma_chan);
-		goto err_out;
-	}
+	if (IS_ERR(i2c_dev->dma_chan))
+		return PTR_ERR(i2c_dev->dma_chan);
 
 	i2c_dev->dma_dev = i2c_dev->dma_chan->device->dev;
 	i2c_dev->dma_buf_size = i2c_dev->hw->quirks->max_write_len +
-- 
2.40.1


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

end of thread, other threads:[~2023-06-08 15:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-08  7:56 [PATCH] i2c: tegra: Fix failure during probe deferral cleanup Thierry Reding
2023-06-08  8:39 ` Andi Shyti
2023-06-08 15:55   ` Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox