linux-i2c.vger.kernel.org archive mirror
 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
* [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 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).