Skip to contentSkip to conversation

i2c: tegra: Fix the check during DMA channel release

PATCH In review Akhil R 3 participants 4 messages Jul 17, 2023 – Aug 6, 2023

Subsystems (3)
lore
Share & tools
lore

Akhil R

author
#0 lore raw

PATCH 1/1 i2c: tegra: Fix the check during DMA channel release

Check for error and NULL before attempting to release DMA channel.

This, otherwise, was causing panic and crash in kernel when the dma_chan has an invalid value. The condition occurs during init_dma() when the dma_request_chan() function returns an error.

Fixes fcc8a89a1c83 ("i2c: tegra: Share same DMA channel for RX and TX")
---
 drivers/i2c/busses/i2c-tegra.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-tegra.c +1 -1
index bcbbf23aa530..636bf340e707 100644
@@ -427,7 +427,7 @@ static void tegra_i2c_release_dma(struct tegra_i2c_dev *i2c_dev)
 		i2c_dev->dma_buf = NULL;
 	}
 
-	if (i2c_dev->dma_chan) {
+	if (!IS_ERR_OR_NULL(i2c_dev->dma_chan)) {
 		dma_release_channel(i2c_dev->dma_chan);
 		i2c_dev->dma_chan = NULL;
 	}
Signature · 1 line
2.17.1
#1 lore raw
Quoted 11 lines · Akhil R

Check for error and NULL before attempting to release DMA channel.

This, otherwise, was causing panic and crash in kernel when the dma_chan has an invalid value. The condition occurs during init_dma() when the dma_request_chan() function returns an error.

Fixes fcc8a89a1c83 ("i2c: tegra: Share same DMA channel for RX and TX")
---
 drivers/i2c/busses/i2c-tegra.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

There's already another patch on the list that should address this:

	https://patchwork.ozlabs.org/project/linux-tegra/patch/[email protected]/

Can you please test and provide feedback on that one?

Thanks,
Thierry

maintainer
#2 lore raw

Hi Thierry and Akhil,

Quoted 7 lines · Thierry Reding
Quoted 6 lines · Akhil R

Check for error and NULL before attempting to release DMA channel.

This, otherwise, was causing panic and crash in kernel when the dma_chan has an invalid value. The condition occurs during init_dma() when the dma_request_chan() function returns an error.

Quoted 5 lines
Quoted 5 lines
Fixes fcc8a89a1c83 ("i2c: tegra: Share same DMA channel for RX and TX")
---
 drivers/i2c/busses/i2c-tegra.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

I guess this patch is not needed anymore.

Andi

author
#3 lore raw
Quoted 10 lines

Hi Thierry and Akhil,

Quoted 7 lines · Thierry Reding
Quoted 6 lines · Akhil R

Check for error and NULL before attempting to release DMA channel.

This, otherwise, was causing panic and crash in kernel when the dma_chan has an invalid value. The condition occurs during init_dma() when the dma_request_chan() function returns an error.

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Fixes fcc8a89a1c83 ("i2c: tegra: Share same DMA channel for RX and

TX")

---
 drivers/i2c/busses/i2c-tegra.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

I guess this patch is not needed anymore.

Correct. This can be discarded.

The below patch from Thierry is for the same fix.
https://lore.kernel.org/linux-i2c/[email protected]/

Regards,
Akhil