Merge pull request #599 from mmichal10/use-after-free
Fix a few memory management related issues
This commit is contained in:
commit
e3a58b93fa
@ -332,6 +332,8 @@ int raw_dynamic_update(ocf_cache_t cache,
|
||||
* RAM DYNAMIC Implementation - Load all
|
||||
*/
|
||||
#define RAW_DYNAMIC_LOAD_PAGES 128
|
||||
#define metadata_io_size(__i_page, __pages_total) \
|
||||
OCF_MIN(RAW_DYNAMIC_LOAD_PAGES, (__pages_total -__i_page))
|
||||
|
||||
struct raw_dynamic_load_all_context {
|
||||
struct ocf_metadata_raw *raw;
|
||||
@ -389,8 +391,7 @@ static int raw_dynamic_load_all_read(struct ocf_request *req)
|
||||
uint64_t count;
|
||||
int result;
|
||||
|
||||
count = OCF_MIN(RAW_DYNAMIC_LOAD_PAGES,
|
||||
raw->ssd_pages - context->i_page);
|
||||
count = metadata_io_size(context->i_page, raw->ssd_pages);
|
||||
|
||||
/* Allocate IO */
|
||||
context->io = ocf_new_cache_io(context->cache, req->io_queue,
|
||||
@ -428,7 +429,7 @@ static int raw_dynamic_load_all_update(struct ocf_request *req)
|
||||
struct raw_dynamic_load_all_context *context = req->priv;
|
||||
struct ocf_metadata_raw *raw = context->raw;
|
||||
ocf_cache_t cache = context->cache;
|
||||
uint64_t count = BYTES_TO_PAGES(context->io->bytes);
|
||||
uint64_t count = metadata_io_size(context->i_page, raw->ssd_pages);
|
||||
int result = 0;
|
||||
|
||||
/* Reset head of data buffer */
|
||||
|
@ -302,12 +302,16 @@ void ocf_core_volume_submit_io(struct ocf_io *io)
|
||||
ocf_core_update_stats(core, io);
|
||||
|
||||
ocf_io_get(io);
|
||||
/* Prevent race condition */
|
||||
ocf_req_get(req);
|
||||
|
||||
if (!ocf_core_submit_io_fast(io, req, core, cache)) {
|
||||
ocf_core_seq_cutoff_update(core, req);
|
||||
ocf_req_put(req);
|
||||
return;
|
||||
}
|
||||
|
||||
ocf_req_put(req);
|
||||
ocf_req_clear_map(req);
|
||||
ocf_core_seq_cutoff_update(core, req);
|
||||
|
||||
|
@ -84,7 +84,7 @@ void ocf_ctx_unregister_volume_type(ocf_ctx_t ctx, uint8_t type_id)
|
||||
{
|
||||
OCF_CHECK_NULL(ctx);
|
||||
|
||||
if (type_id < OCF_VOLUME_TYPE_MAX_USER)
|
||||
if (type_id < OCF_VOLUME_TYPE_MAX)
|
||||
ocf_ctx_unregister_volume_type_internal(ctx, type_id);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user