public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] Use after free in mtd/phram.c: unregister_devices()
@ 2005-02-23  8:43 Alexander Nyberg
  2005-02-23 13:05 ` Jörn Engel
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Nyberg @ 2005-02-23  8:43 UTC (permalink / raw)
  To: joern; +Cc: linux-mtd

Use after free, found by the Coverity tool

Signed-off-by: Alexander Nyberg <alexn@dsv.su.se>

===== drivers/mtd/devices/phram.c 1.6 vs edited =====
--- 1.6/drivers/mtd/devices/phram.c	2005-01-05 19:08:36 +01:00
+++ edited/drivers/mtd/devices/phram.c	2005-02-23 09:29:59 +01:00
@@ -107,9 +107,9 @@ static int phram_write(struct mtd_info *
 
 static void unregister_devices(void)
 {
-	struct phram_mtd_list *this;
+	struct phram_mtd_list *this, *safe;
 
-	list_for_each_entry(this, &phram_list, list) {
+	list_for_each_entry_safe(this, safe, &phram_list, list) {
 		del_mtd_device(&this->mtd);
 		iounmap(this->mtd.priv);
 		kfree(this);

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

* Re: [PATCH] Use after free in mtd/phram.c: unregister_devices()
  2005-02-23  8:43 [PATCH] Use after free in mtd/phram.c: unregister_devices() Alexander Nyberg
@ 2005-02-23 13:05 ` Jörn Engel
  0 siblings, 0 replies; 2+ messages in thread
From: Jörn Engel @ 2005-02-23 13:05 UTC (permalink / raw)
  To: Alexander Nyberg; +Cc: linux-mtd, joern

On Wed, 23 February 2005 09:43:25 +0100, Alexander Nyberg wrote:
> 
> Use after free, found by the Coverity tool

Thanks!

> Signed-off-by: Alexander Nyberg <alexn@dsv.su.se>
> 
> ===== drivers/mtd/devices/phram.c 1.6 vs edited =====
> --- 1.6/drivers/mtd/devices/phram.c	2005-01-05 19:08:36 +01:00
> +++ edited/drivers/mtd/devices/phram.c	2005-02-23 09:29:59 +01:00
> @@ -107,9 +107,9 @@ static int phram_write(struct mtd_info *
>  
>  static void unregister_devices(void)
>  {
> -	struct phram_mtd_list *this;
> +	struct phram_mtd_list *this, *safe;
>  
> -	list_for_each_entry(this, &phram_list, list) {
> +	list_for_each_entry_safe(this, safe, &phram_list, list) {
>  		del_mtd_device(&this->mtd);
>  		iounmap(this->mtd.priv);
>  		kfree(this);
> 

Jörn

-- 
But this is not to say that the main benefit of Linux and other GPL
software is lower-cost. Control is the main benefit--cost is secondary.
-- Bruce Perens

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

end of thread, other threads:[~2005-02-23 13:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-23  8:43 [PATCH] Use after free in mtd/phram.c: unregister_devices() Alexander Nyberg
2005-02-23 13:05 ` Jörn Engel

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