linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gao Pan <b54642@freescale.com>
To: wsa@the-dreams.de, u.kleine-koenig@pengutronix.de
Cc: linux-i2c@vger.kernel.org, B20596@freescale.com,
	b38611@freescale.com, b54642@freescale.com,
	kernel@pengutronix.de, s.hauer@pengutronix.de,
	p.zabel@pengutronix.de, yao.yuan@freescale.com
Subject: [Patch V1] imx: i2c: fix i2c resource leak with dma transfer
Date: Wed, 2 Dec 2015 17:52:38 +0800	[thread overview]
Message-ID: <1449049958-6820-1-git-send-email-b54642@freescale.com> (raw)

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

             reply	other threads:[~2015-12-02 10:09 UTC|newest]

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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1449049958-6820-1-git-send-email-b54642@freescale.com \
    --to=b54642@freescale.com \
    --cc=B20596@freescale.com \
    --cc=b38611@freescale.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-i2c@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=s.hauer@pengutronix.de \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=wsa@the-dreams.de \
    --cc=yao.yuan@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).