blobstore: Hold the original buffer to free it when realloc() is failed
Change-Id: I1f2c62b2607fb6efb82c9de59244ba3e32fa67ca Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/412753 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
db9f7d3992
commit
57d93c9ecb
@ -1277,6 +1277,7 @@ _spdk_blob_persist_start(struct spdk_blob_persist_ctx *ctx)
|
||||
struct spdk_blob_store *bs = blob->bs;
|
||||
uint64_t i;
|
||||
uint32_t page_num;
|
||||
void *tmp;
|
||||
int rc;
|
||||
|
||||
if (blob->active.num_pages == 0) {
|
||||
@ -1300,12 +1301,12 @@ _spdk_blob_persist_start(struct spdk_blob_persist_ctx *ctx)
|
||||
assert(blob->active.num_pages >= 1);
|
||||
|
||||
/* Resize the cache of page indices */
|
||||
blob->active.pages = realloc(blob->active.pages,
|
||||
blob->active.num_pages * sizeof(*blob->active.pages));
|
||||
if (!blob->active.pages) {
|
||||
tmp = realloc(blob->active.pages, blob->active.num_pages * sizeof(*blob->active.pages));
|
||||
if (!tmp) {
|
||||
_spdk_blob_persist_complete(seq, ctx, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
blob->active.pages = tmp;
|
||||
|
||||
/* Assign this metadata to pages. This requires two passes -
|
||||
* one to verify that there are enough pages and a second
|
||||
|
Loading…
x
Reference in New Issue
Block a user