[PATCH] mtd: fix memory leak
Artem Bityutskiy
dedekind1 at gmail.com
Sun Jan 30 09:52:33 EST 2011
Hi,
On Sun, 2011-01-30 at 10:31 +0100, Mathias Krause wrote:
> diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
> index 5239328..8d28fa0 100644
> --- a/drivers/mtd/devices/phram.c
> +++ b/drivers/mtd/devices/phram.c
> @@ -117,6 +117,7 @@ static void unregister_devices(void)
> list_for_each_entry_safe(this, safe, &phram_list, list) {
> del_mtd_device(&this->mtd);
> iounmap(this->mtd.priv);
> + kfree(this->mtd.name);
> kfree(this);
> }
Since register_device() did not allocate it, unregister_devices() should
not free it. Hence, I think it is better to free(name) just after
calling unregister_devices().
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
More information about the linux-mtd
mailing list