mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
Use dm_free for dm_malloc-ed areas in _clog_ctr/_clog_dtr (cmirrord).
Use dm_zalloc to obtain zeroed memory block. Use dm_free for dm_ allocated memory blocks. Test close() for error.
This commit is contained in:
parent
f7e7f3e3ed
commit
9d3be13f4f
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.79 -
|
Version 2.02.79 -
|
||||||
===================================
|
===================================
|
||||||
|
Use dm_free for dm_malloc-ed areas in _clog_ctr/_clog_dtr (cmirrord).
|
||||||
Add checks for allocation errors in config node clonning.
|
Add checks for allocation errors in config node clonning.
|
||||||
Fix error path if regex engine cannot be created in _build_matcher().
|
Fix error path if regex engine cannot be created in _build_matcher().
|
||||||
Use char* arithmetic in target_version(), _process_all(), _targets().
|
Use char* arithmetic in target_version(), _process_all(), _targets().
|
||||||
|
@ -429,13 +429,12 @@ static int _clog_ctr(char *uuid, uint64_t luid,
|
|||||||
block_on_error = 1;
|
block_on_error = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
lc = malloc(sizeof(*lc));
|
lc = dm_zalloc(sizeof(*lc));
|
||||||
if (!lc) {
|
if (!lc) {
|
||||||
LOG_ERROR("Unable to allocate cluster log context");
|
LOG_ERROR("Unable to allocate cluster log context");
|
||||||
r = -ENOMEM;
|
r = -ENOMEM;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
memset(lc, 0, sizeof(*lc));
|
|
||||||
|
|
||||||
lc->region_size = region_size;
|
lc->region_size = region_size;
|
||||||
lc->region_count = region_count;
|
lc->region_count = region_count;
|
||||||
@ -453,7 +452,7 @@ static int _clog_ctr(char *uuid, uint64_t luid,
|
|||||||
(duplicate = get_pending_log(lc->uuid, lc->luid))) {
|
(duplicate = get_pending_log(lc->uuid, lc->luid))) {
|
||||||
LOG_ERROR("[%s/%" PRIu64 "u] Log already exists, unable to create.",
|
LOG_ERROR("[%s/%" PRIu64 "u] Log already exists, unable to create.",
|
||||||
SHORT_UUID(lc->uuid), lc->luid);
|
SHORT_UUID(lc->uuid), lc->luid);
|
||||||
free(lc);
|
dm_free(lc);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,15 +510,13 @@ static int _clog_ctr(char *uuid, uint64_t luid,
|
|||||||
return 0;
|
return 0;
|
||||||
fail:
|
fail:
|
||||||
if (lc) {
|
if (lc) {
|
||||||
if (lc->clean_bits)
|
if (lc->disk_fd >= 0 && close(lc->disk_fd))
|
||||||
free(lc->clean_bits);
|
LOG_ERROR("Close device error, %s: %s",
|
||||||
if (lc->sync_bits)
|
disk_path, strerror(errno));
|
||||||
free(lc->sync_bits);
|
free(lc->disk_buffer);
|
||||||
if (lc->disk_buffer)
|
dm_free(lc->sync_bits);
|
||||||
free(lc->disk_buffer);
|
dm_free(lc->clean_bits);
|
||||||
if (lc->disk_fd >= 0)
|
dm_free(lc);
|
||||||
close(lc->disk_fd);
|
|
||||||
free(lc);
|
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@ -634,9 +631,9 @@ static int clog_dtr(struct dm_ulog_request *rq)
|
|||||||
close(lc->disk_fd);
|
close(lc->disk_fd);
|
||||||
if (lc->disk_buffer)
|
if (lc->disk_buffer)
|
||||||
free(lc->disk_buffer);
|
free(lc->disk_buffer);
|
||||||
free(lc->clean_bits);
|
dm_free(lc->clean_bits);
|
||||||
free(lc->sync_bits);
|
dm_free(lc->sync_bits);
|
||||||
free(lc);
|
dm_free(lc);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user