linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@the-dreams.de>
To: Gao Pan <b54642@freescale.com>
Cc: u.kleine-koenig@pengutronix.de, linux-i2c@vger.kernel.org,
	B20596@freescale.com, b38611@freescale.com,
	kernel@pengutronix.de, s.hauer@pengutronix.de,
	p.zabel@pengutronix.de, yao.yuan@freescale.com
Subject: Re: [Patch V1] imx: i2c: fix i2c resource leak with dma transfer
Date: Mon, 4 Jan 2016 20:32:34 +0100	[thread overview]
Message-ID: <20160104193234.GC1522@katana> (raw)
In-Reply-To: <1449049958-6820-1-git-send-email-b54642@freescale.com>

[-- 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 --]

  reply	other threads:[~2016-01-04 19:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-02  9:52 [Patch V1] imx: i2c: fix i2c resource leak with dma transfer Gao Pan
2016-01-04 19:32 ` Wolfram Sang [this message]
  -- 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=20160104193234.GC1522@katana \
    --to=wsa@the-dreams.de \
    --cc=B20596@freescale.com \
    --cc=b38611@freescale.com \
    --cc=b54642@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=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).