public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Artem Bityutskiy <dedekind1@gmail.com>
To: Julia Lawall <julia@diku.dk>
Cc: kernel-janitors@vger.kernel.org,
	David Woodhouse <dwmw2@infradead.org>,
	linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org
Subject: Re: [PATCH 2/2] drivers/mtd/maps/lantiq-flash.c: drop iounmap for devm_ allocated data
Date: Tue, 27 Dec 2011 10:23:56 +0200	[thread overview]
Message-ID: <1324974236.1165.43.camel@sauron.fi.intel.com> (raw)
In-Reply-To: <1324921081-13161-2-git-send-email-julia@diku.dk>

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

On Mon, 2011-12-26 at 18:38 +0100, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> Data allocated with devm_ioremap or devm_ioremap_nocache should not be
> freed using iounmap, because doing so causes a dangling pointer, and a
> subsequent double free.
> 
> The semantic match that finds this problem is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @r@
> expression x;
> @@
> (
>  x = devm_ioremap(...)
> |
>  x = devm_ioremap_nocache(...)
> )
> 
> @@
> expression r.x;
> @@
> * iounmap(x)
> // </smpl>

Thanks Julia,

surely this semantic patch script is worth adding to scripts/coccinelle?
Are you going to take care of this?

> 
> Signed-off-by: Julia Lawall <julia@diku.dk>
> 
> ---
>  drivers/mtd/maps/lantiq-flash.c |    6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/mtd/maps/lantiq-flash.c b/drivers/mtd/maps/lantiq-flash.c
> index 4f10e27..7b889de 100644
> --- a/drivers/mtd/maps/lantiq-flash.c
> +++ b/drivers/mtd/maps/lantiq-flash.c
> @@ -159,7 +159,7 @@ ltq_mtd_probe(struct platform_device *pdev)
>  	if (!ltq_mtd->mtd) {
>  		dev_err(&pdev->dev, "probing failed\n");
>  		err = -ENXIO;
> -		goto err_unmap;
> +		goto err_free;
>  	}

Pushed to l2-mtd-2.6.git, thanks!

-- 
Best Regards,
Artem Bityutskiy

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2011-12-27  8:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-26 17:38 [PATCH 2/2] drivers/mtd/maps/lantiq-flash.c: drop iounmap for devm_ allocated data Julia Lawall
2011-12-27  8:23 ` Artem Bityutskiy [this message]
2011-12-27  8:36   ` Julia Lawall

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=1324974236.1165.43.camel@sauron.fi.intel.com \
    --to=dedekind1@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=julia@diku.dk \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    /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