ubi fastmap memory leak

richard -rw- weinberger richard.weinberger at gmail.com
Thu Apr 11 10:53:15 EDT 2013


Hi!

On Thu, Apr 11, 2013 at 11:23 AM,  <wang.bo116 at zte.com.cn> wrote:
> Hello,
>         When use ubi fastmap,i think there is a memory leak in
> "ubi_attach" function.Think about this scene:
>
>         1. In "ubi_attach" function, "alloc_ai" function called to alloc a
> slab cache named "ubi_aeb_slab_cache".
>         Then use "ai->aeb_slab_cache" to record the cache.
>
>         2. ubi_attach -> scan_fast -> ubi_scan_fastmap ->
> ubi_attach_fastmap,
>         in "ubi_attach_fastmap" function, slab cache named
> "ubi_ainf_peb_slab" will be alloced.
>         Because of this slab cache also recorded in "ai->aeb_slab_cache",
> so, in fact it overwrite the previously one.
>
>         3. When "destroy_ai" called , it only free "ubi_ainf_peb_slab".
>
>         I made a patch base on Linux 3.9-rc6, it fix this problem use a
> temporary ai for fastmap scan.
>         During my test, this patch like work good.

So, we call ubi_scan_fastmap() with an ai where ->aeb_slab_cache
points already to a
slab cache?
I think it would be best to remove the kmem_cache_create() from
ubi_scan_fastmap()
completely.

What do you think?

--
Thanks,
//richard



More information about the linux-mtd mailing list