All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch v1] imx: i2c: fix i2c resource leak with dma transfer
@ 2016-01-08  5:33 Gao Pan
  2016-01-10  9:07 ` Wolfram Sang
  0 siblings, 1 reply; 4+ messages in thread
From: Gao Pan @ 2016-01-08  5:33 UTC (permalink / raw)
  To: wsa, u.kleine-koenig; +Cc: linux-i2c, frank.li, fugang.duan, pandy.gao, kernel

In i2c_imx_dma_xfer(), when dmaengine_submit() returns error,
the context goto label err_submit and then return. However, the
memory allocated for txdesc has not been freed yet, which
leads to resource leak.

Signed-off-by: Gao Pan <b54642@freescale.com>
Signed-off-by: Fugang Duan <B38611@freescale.com>
---
 drivers/i2c/busses/i2c-imx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 8b68dbf..a2b132c 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -387,6 +387,7 @@ static int i2c_imx_dma_xfer(struct imx_i2c_struct *i2c_imx,
 	return 0;
 
 err_submit:
+	dmaengine_terminate_all(dma->chan_using);
 err_desc:
 	dma_unmap_single(chan_dev, dma->dma_buf,
 			dma->dma_len, dma->dma_data_dir);
-- 
1.9.1

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

* Re: [Patch v1] imx: i2c: fix i2c resource leak with dma transfer
  2016-01-08  5:33 [Patch v1] imx: i2c: fix i2c resource leak with dma transfer Gao Pan
@ 2016-01-10  9:07 ` Wolfram Sang
  0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2016-01-10  9:07 UTC (permalink / raw)
  To: Gao Pan; +Cc: u.kleine-koenig, linux-i2c, frank.li, fugang.duan, kernel

[-- Attachment #1: Type: text/plain, Size: 418 bytes --]

On Fri, Jan 08, 2016 at 01:33:15PM +0800, Gao Pan wrote:
> In i2c_imx_dma_xfer(), when dmaengine_submit() returns error,
> the context goto label err_submit and then return. However, the
> memory allocated for txdesc has not been freed yet, which
> leads to resource leak.
> 
> Signed-off-by: Gao Pan <b54642@freescale.com>
> Signed-off-by: Fugang Duan <B38611@freescale.com>

Applied to for-next, thanks!


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [Patch V1] imx: i2c: fix i2c resource leak with dma transfer
  2015-12-02  9:52 [Patch V1] " Gao Pan
@ 2016-01-04 19:32 ` Wolfram Sang
  0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2016-01-04 19:32 UTC (permalink / raw)
  To: Gao Pan
  Cc: u.kleine-koenig, linux-i2c, B20596, b38611, kernel, s.hauer,
	p.zabel, yao.yuan

[-- Attachment #1: Type: text/plain, Size: 1113 bytes --]

On Wed, Dec 02, 2015 at 05:52:38PM +0800, Gao Pan wrote:
> In i2c_imx_dma_xfer(), when dmaengine_prep_slave_single() returns
> NULL, the context goto label err_desc and then return. However,
> the memory allocated by dmaengine_prep_slave_single() has not been
> freed yet, which leads to resource leak.

dmaengine_prep_slave_single() still owns allocated memory although it
returns NULL? Isn't this a bug?

> 
> (reported by coverity check)
> 
> Signed-off-by: Gao Pan <b54642@freescale.com>
> Signed-off-by: Fugang Duan <B38611@freescale.com>
> ---
>  drivers/i2c/busses/i2c-imx.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 0ab8424..6dcfff5 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -397,6 +397,7 @@ static int i2c_imx_dma_xfer(struct imx_i2c_struct *i2c_imx,
>  
>  err_submit:
>  err_desc:
> +	dmaengine_terminate_all(dma->chan_using);
>  	dma_unmap_single(chan_dev, dma->dma_buf,
>  			dma->dma_len, dma->dma_data_dir);
>  err_map:
> -- 
> 1.9.1
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [Patch V1] imx: i2c: fix i2c resource leak with dma transfer
@ 2015-12-02  9:52 Gao Pan
  2016-01-04 19:32 ` Wolfram Sang
  0 siblings, 1 reply; 4+ messages in thread
From: Gao Pan @ 2015-12-02  9:52 UTC (permalink / raw)
  To: wsa, u.kleine-koenig
  Cc: linux-i2c, B20596, b38611, b54642, kernel, s.hauer, p.zabel, yao.yuan

In i2c_imx_dma_xfer(), when dmaengine_prep_slave_single() returns
NULL, the context goto label err_desc and then return. However,
the memory allocated by dmaengine_prep_slave_single() has not been
freed yet, which leads to resource leak.

(reported by coverity check)

Signed-off-by: Gao Pan <b54642@freescale.com>
Signed-off-by: Fugang Duan <B38611@freescale.com>
---
 drivers/i2c/busses/i2c-imx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 0ab8424..6dcfff5 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -397,6 +397,7 @@ static int i2c_imx_dma_xfer(struct imx_i2c_struct *i2c_imx,
 
 err_submit:
 err_desc:
+	dmaengine_terminate_all(dma->chan_using);
 	dma_unmap_single(chan_dev, dma->dma_buf,
 			dma->dma_len, dma->dma_data_dir);
 err_map:
-- 
1.9.1

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

end of thread, other threads:[~2016-01-10  9:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-08  5:33 [Patch v1] imx: i2c: fix i2c resource leak with dma transfer Gao Pan
2016-01-10  9:07 ` Wolfram Sang
  -- strict thread matches above, loose matches on Subject: below --
2015-12-02  9:52 [Patch V1] " Gao Pan
2016-01-04 19:32 ` Wolfram Sang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.