From: Ryusuke Konishi <[email protected]>

The start_deletion function does not free the deletion_work structure
nor the buffer (dw->buf) that it locally allocated when it deletes
inode of the VDI or dw->count was equal to zero.

This fixes these leak bugs.

Signed-off-by: Ryusuke Konishi <[email protected]>
Reviewed-by:Hitoshi Mitake <[email protected]>
Signed-off-by: Liu Yuan <[email protected]>
---
 sheep/vdi.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sheep/vdi.c b/sheep/vdi.c
index 1e05e4f..2252702 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -830,7 +830,7 @@ static int start_deletion(struct request *req, uint32_t vid)
        root_vid = get_vdi_root(dw->vid, &cloned);
        if (!root_vid) {
                ret = SD_RES_EIO;
-               goto err;
+               goto out;
        }
 
        ret = fill_vdi_list(dw, root_vid);
@@ -846,12 +846,14 @@ static int start_deletion(struct request *req, uint32_t 
vid)
                        sd_debug("snapshot chain has valid vdi, just mark vdi %"
                                 PRIx32 " as deleted.", dw->vid);
                        delete_inode(dw);
-                       return SD_RES_SUCCESS;
+                       ret = SD_RES_SUCCESS;
+                       goto out;
                }
        }
 
        sd_debug("%d", dw->count);
 
+       ret = SD_RES_SUCCESS;
        if (dw->count == 0)
                goto out;
 
@@ -862,9 +864,9 @@ static int start_deletion(struct request *req, uint32_t vid)
                queue_work(sys->deletion_wqueue, &dw->work);
        } else
                list_add_tail(&dw->list, &deletion_work_list);
+
+       return ret;
 out:
-       return SD_RES_SUCCESS;
-err:
        if (dw)
                free(dw->buf);
        free(dw);
-- 
1.7.10.4

-- 
sheepdog mailing list
[email protected]
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to