2023-07-17 15:29:50

by Akhil R

[permalink] [raw]
Subject: [PATCH] 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")
Signed-off-by: Akhil R <[email protected]>
---
drivers/i2c/busses/i2c-tegra.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index bcbbf23aa530..636bf340e707 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -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;
}
--
2.17.1



2023-07-17 16:26:16

by Thierry Reding

[permalink] [raw]
Subject: Re: [PATCH] i2c: tegra: Fix the check during DMA channel release

On Mon, Jul 17, 2023 at 08:42:40PM +0530, Akhil R wrote:
> 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")
> Signed-off-by: Akhil R <[email protected]>
> ---
> 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


Attachments:
(No filename) (818.00 B)
signature.asc (849.00 B)
Download all attachments

2023-08-05 13:15:59

by Andi Shyti

[permalink] [raw]
Subject: Re: [PATCH] i2c: tegra: Fix the check during DMA channel release

Hi Thierry and Akhil,

On Mon, Jul 17, 2023 at 05:24:15PM +0200, Thierry Reding wrote:
> On Mon, Jul 17, 2023 at 08:42:40PM +0530, Akhil R wrote:
> > 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")
> > Signed-off-by: Akhil R <[email protected]>
> > ---
> > drivers/i2c/busses/i2c-tegra.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)

I guess this patch is not needed anymore.

Andi

2023-08-06 15:12:27

by Akhil R

[permalink] [raw]
Subject: RE: [PATCH] i2c: tegra: Fix the check during DMA channel release

> Hi Thierry and Akhil,
>
> On Mon, Jul 17, 2023 at 05:24:15PM +0200, Thierry Reding wrote:
> > On Mon, Jul 17, 2023 at 08:42:40PM +0530, Akhil R wrote:
> > > 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")
> > > Signed-off-by: Akhil R <[email protected]>
> > > ---
> > > 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