mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/6] drivers/dma: Correct use after free
@ 2009-12-22 20:30 Julia Lawall
  2009-12-22 22:17 ` Dan Williams
  2009-12-23 15:08 ` Sosnowski, Maciej
  0 siblings, 2 replies; 3+ messages in thread
From: Julia Lawall @ 2009-12-22 20:30 UTC (permalink / raw)
  To: Dan Williams, Maciej Sosnowski, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

Move the kfree after the iounmap that refers to the same structure.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x,e;
identifier f;
iterator I;
statement S;
@@

*kfree(x);
... when != &x
    when != x = e
    when != I(x,...) S
*x->f
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/dma/coh901318.c             |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/dma/coh901318.c b/drivers/dma/coh901318.c
index 4a99cd9..b5f2ee0 100644
--- a/drivers/dma/coh901318.c
+++ b/drivers/dma/coh901318.c
@@ -1294,8 +1294,8 @@ static int __exit coh901318_remove(struct platform_device *pdev)
 	dma_async_device_unregister(&base->dma_slave);
 	coh901318_pool_destroy(&base->pool);
 	free_irq(platform_get_irq(pdev, 0), base);
-	kfree(base);
 	iounmap(base->virtbase);
+	kfree(base);
 	release_mem_region(pdev->resource->start,
 			   resource_size(pdev->resource));
 	return 0;

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

* Re: [PATCH 1/6] drivers/dma: Correct use after free
  2009-12-22 20:30 [PATCH 1/6] drivers/dma: Correct use after free Julia Lawall
@ 2009-12-22 22:17 ` Dan Williams
  2009-12-23 15:08 ` Sosnowski, Maciej
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Williams @ 2009-12-22 22:17 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Maciej Sosnowski, linux-kernel, kernel-janitors

On Tue, Dec 22, 2009 at 1:30 PM, Julia Lawall <julia@diku.dk> wrote:
> From: Julia Lawall <julia@diku.dk>
>
> Move the kfree after the iounmap that refers to the same structure.
>

Thanks Julia.  I'll apply this one and the kzalloc versus memset one
you sent earlier.

--
Dan

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

* RE: [PATCH 1/6] drivers/dma: Correct use after free
  2009-12-22 20:30 [PATCH 1/6] drivers/dma: Correct use after free Julia Lawall
  2009-12-22 22:17 ` Dan Williams
@ 2009-12-23 15:08 ` Sosnowski, Maciej
  1 sibling, 0 replies; 3+ messages in thread
From: Sosnowski, Maciej @ 2009-12-23 15:08 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Williams, Dan J, linux-kernel, kernel-janitors

Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> Move the kfree after the iounmap that refers to the same structure.
> 
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @@
> expression x,e;
> identifier f;
> iterator I;
> statement S;
> @@
> 
> *kfree(x);
> ... when != &x
>     when != x = e
>     when != I(x,...) S
> *x->f
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>
> 
> ---
>  drivers/dma/coh901318.c             |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/dma/coh901318.c b/drivers/dma/coh901318.c
> index 4a99cd9..b5f2ee0 100644
> --- a/drivers/dma/coh901318.c
> +++ b/drivers/dma/coh901318.c
> @@ -1294,8 +1294,8 @@ static int __exit coh901318_remove(struct platform_device *pdev)
>  	dma_async_device_unregister(&base->dma_slave);
>  	coh901318_pool_destroy(&base->pool);
>  	free_irq(platform_get_irq(pdev, 0), base);
> -	kfree(base);
>  	iounmap(base->virtbase);
> +	kfree(base);
>  	release_mem_region(pdev->resource->start,
>  			   resource_size(pdev->resource));
>  	return 0;

Acked-by: Maciej Sosnowski <maciej.sosnowski@intel.com>

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

end of thread, other threads:[~2009-12-23 15:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-22 20:30 [PATCH 1/6] drivers/dma: Correct use after free Julia Lawall
2009-12-22 22:17 ` Dan Williams
2009-12-23 15:08 ` Sosnowski, Maciej

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®