blobstore:fix memleak problem in blob_load_cpl()
In blob_load_cpl(), spdk_realloc() is called to realloc memory of ctx->pages. If spdk_realloc() return NULL, the ctx->pages is set to NULL without being freed, and then a memleak problem occurs. Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Change-Id: Idf21b690e89beab0245ba57a5de66a4f506d54fb Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8308 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
59c8bb527b
commit
aafc440e9c
@ -1494,16 +1494,18 @@ blob_load_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
}
|
||||
|
||||
if (page->next != SPDK_INVALID_MD_PAGE) {
|
||||
struct spdk_blob_md_page *tmp_pages;
|
||||
uint32_t next_page = page->next;
|
||||
uint64_t next_lba = bs_md_page_to_lba(blob->bs, next_page);
|
||||
|
||||
/* Read the next page */
|
||||
ctx->num_pages++;
|
||||
ctx->pages = spdk_realloc(ctx->pages, (sizeof(*page) * ctx->num_pages), 0);
|
||||
if (ctx->pages == NULL) {
|
||||
tmp_pages = spdk_realloc(ctx->pages, (sizeof(*page) * (ctx->num_pages + 1)), 0);
|
||||
if (tmp_pages == NULL) {
|
||||
blob_load_final(ctx, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
ctx->num_pages++;
|
||||
ctx->pages = tmp_pages;
|
||||
|
||||
bs_sequence_read_dev(seq, &ctx->pages[ctx->num_pages - 1],
|
||||
next_lba,
|
||||
|
Loading…
Reference in New Issue
Block a user