Message ID | 1445254680-11102-8-git-send-email-guaneryu@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
diff --git a/chunk-recover.c b/chunk-recover.c index 1fb04f7..c727f0f 100644 --- a/chunk-recover.c +++ b/chunk-recover.c @@ -847,11 +847,16 @@ static int scan_devices(struct recover_control *rc) if (!dev_scans) return -ENOMEM; t_scans = (pthread_t *)malloc(sizeof(pthread_t) * devnr); - if (!t_scans) + if (!t_scans) { + free(dev_scans); return -ENOMEM; + } t_rets = (long *)malloc(sizeof(long) * devnr); - if (!t_rets) + if (!t_rets) { + free(dev_scans); + free(t_scans); return -ENOMEM; + } list_for_each_entry(dev, &rc->fs_devices->devices, dev_list) { fd = open(dev->name, O_RDONLY);
dev_scans and t_scans should be freed on malloc error. Signed-off-by: Eryu Guan <guaneryu@gmail.com> --- chunk-recover.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)