[PATCH] Use after free in mtd/phram.c: unregister_devices()

Jörn Engel joern at wohnheim.fh-wedel.de
Wed Feb 23 08:05:40 EST 2005


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 at 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




More information about the linux-mtd mailing list