mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
Add missing test for failed pool allocation
Add test for NULL from dm_poll_create. Reorder dm_pool_destroy() before file close and add label out:. Avoid leaking file descriptor if the allocation fails.
This commit is contained in:
parent
a8d4cd68eb
commit
14caa4a2d0
@ -1,5 +1,6 @@
|
||||
Version 2.02.78 -
|
||||
====================================
|
||||
Add missing test for failed pool allocation in write_config_node().
|
||||
Replace snprintf with dm_snprintf in clvmd-command.c.
|
||||
Check reallocated buffer for NULL before use in clvmd do_command().
|
||||
Fix memory leak when VG allocation policy in metadata is invalid.
|
||||
|
@ -511,7 +511,8 @@ int write_config_node(const struct config_node *cn, putline_fn putline, void *ba
|
||||
{
|
||||
struct output_line outline;
|
||||
outline.fp = NULL;
|
||||
outline.mem = dm_pool_create("config_line", 1024);
|
||||
if (!(outline.mem = dm_pool_create("config_line", 1024)))
|
||||
return_0;
|
||||
outline.putline = putline;
|
||||
outline.putline_baton = baton;
|
||||
if (!_write_config(cn, 0, &outline, 0)) {
|
||||
@ -538,7 +539,10 @@ int write_config_file(struct config_tree *cft, const char *file,
|
||||
return 0;
|
||||
}
|
||||
|
||||
outline.mem = dm_pool_create("config_line", 1024);
|
||||
if (!(outline.mem = dm_pool_create("config_line", 1024))) {
|
||||
r = 0;
|
||||
goto_out;
|
||||
}
|
||||
|
||||
log_verbose("Dumping configuration to %s", file);
|
||||
if (!argc) {
|
||||
@ -559,12 +563,14 @@ int write_config_file(struct config_tree *cft, const char *file,
|
||||
argv++;
|
||||
}
|
||||
|
||||
dm_pool_destroy(outline.mem);
|
||||
|
||||
out:
|
||||
if (outline.fp && lvm_fclose(outline.fp, file)) {
|
||||
stack;
|
||||
r = 0;
|
||||
}
|
||||
|
||||
dm_pool_destroy(outline.mem);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user