1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-02-04 21:47:46 +03:00

coverity: fix resource leaks

LVM2.2.02.112/tools/toollib.c:1991: leaked_storage: Variable "iter" going out of scope leaks the storage it points to.
LVM2.2.02.112/lib/filters/filter-usable.c:89: leaked_storage: Variable "f" going out of scope leaks the storage it points to.
LVM2.2.02.112/lib/activate/dev_manager.c:1874: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
This commit is contained in:
Peter Rajnoha 2014-11-12 09:18:55 +01:00
parent 131aaeb634
commit ba23023464
3 changed files with 8 additions and 3 deletions

View File

@ -1870,6 +1870,8 @@ static int _pool_callback(struct dm_tree_node *node,
}
/* let's assume there is no problem to read 64 bytes */
if (read(fd, buf, sizeof(buf)) < sizeof(buf)) {
if (close(fd))
log_sys_error("close", argv[args]);
log_sys_error("read", argv[args]);
return 0;
}

View File

@ -86,6 +86,7 @@ struct dev_filter *usable_filter_create(struct dev_types *dt __attribute__((unus
f->use_count = 0;
if (!(f->private = dm_zalloc(sizeof(filter_mode_t)))) {
log_error("Usable device filter mode allocation failed");
dm_free(f);
return NULL;
}
*((filter_mode_t *) f->private) = mode;

View File

@ -1977,6 +1977,7 @@ static int _get_all_devices(struct cmd_context *cmd, struct dm_list *all_devices
struct dev_iter *iter;
struct device *dev;
struct device_list *devl;
int r = ECMD_FAILED;
lvmcache_seed_infos_from_lvmetad(cmd);
@ -1988,16 +1989,17 @@ static int _get_all_devices(struct cmd_context *cmd, struct dm_list *all_devices
while ((dev = dev_iter_get(iter))) {
if (!(devl = dm_pool_alloc(cmd->mem, sizeof(*devl)))) {
log_error("device_list alloc failed");
return ECMD_FAILED;
goto out;
}
devl->dev = dev;
dm_list_add(all_devices, &devl->list);
}
r = ECMD_PROCESSED;
out:
dev_iter_destroy(iter);
return ECMD_PROCESSED;
return r;
}
static int _device_list_remove(struct dm_list *all_devices, struct device *dev)