[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [RFC Patch v3 09/18] block-remus: fix memory leak



On Sep 5, 2014 5:15 AM, "Wen Congyang" <wency@xxxxxxxxxxxxxx> wrote:
>
> Fix the following two memory leak:
> 1. If s->ramdisk.prev is not NULL, we merge the write requests in
> Â Âs->ramdisk.h into s->ramdisk.prev, and then destroy s->ramdisk.h.
> Â ÂBut we forget to free hash value when destroying s->ramdisk.h.

I am responding from my phone. So I don't have the code in hand to validate your claim. I think the merge function reuses the value block (write request) instead of doing a memcpy. In which case, this patch will be freeing the buffer that is queued for write. Is that right?

> 2. When write requests is finished, replicated_write_callback() will
> Â Âbe called. We forget free the buff in this function.

Wasn't that done explicitly in the write req done function, where a free(buf) was introduced? (Vague recollection... I am not sure if I pushed that fix upstream either :( )

Either way, if you have a working Remus setup, can you confirm that this patch does not cause double free error? (Just this patch and no other Remus related fixes).

>
> Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
> Signed-off-by: Jiang Yunhong <yunhong.jiang@xxxxxxxxx>
> Signed-off-by: Wen Congyang <wency@xxxxxxxxxxxxxx>
> Cc: Shriram Rajagopalan <rshriram@xxxxxxxxx>
> ---
> Âtools/blktap2/drivers/block-remus.c | 2 +-
> Â1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/blktap2/drivers/block-remus.c b/tools/blktap2/drivers/block-remus.c
> index 079588d..4ce9dbe 100644
> --- a/tools/blktap2/drivers/block-remus.c
> +++ b/tools/blktap2/drivers/block-remus.c
> @@ -602,7 +602,7 @@ static int ramdisk_start_flush(td_driver_t *driver)
> Â Â Â Â Â Â Â Â }
> Â Â Â Â Â Â Â Â free(sectors);
>
> -Â Â Â Â Â Â Â Âhashtable_destroy (s->ramdisk.h, 0);
> +Â Â Â Â Â Â Â Âhashtable_destroy (s->ramdisk.h, 1);
> Â Â Â Â } else
> Â Â Â Â Â Â Â Â s->ramdisk.prev = s->ramdisk.h;
>
> --
> 1.9.3
>

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.