blobfs: Add missing error checks for strdup.
Here were some cases for file->name using strdup missing check for no memory, but some had. So add them. Signed-off-by: yidong0635 <dongx.yi@intel.com> Change-Id: I91feeea3711f127135aedf37e53624811a4ab5e8 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11989 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
ebf077cbf8
commit
57eee18288
@ -750,6 +750,14 @@ iter_cb(void *ctx, struct spdk_blob *blob, int rc)
|
||||
}
|
||||
|
||||
f->name = strdup(name);
|
||||
if (!f->name) {
|
||||
SPDK_ERRLOG("Cannot allocate memory for file name\n");
|
||||
args->fn.fs_op_with_handle(args->arg, fs, -ENOMEM);
|
||||
free_fs_request(req);
|
||||
file_free(f);
|
||||
return;
|
||||
}
|
||||
|
||||
f->blobid = spdk_blob_get_id(blob);
|
||||
f->length = *length;
|
||||
f->length_flushed = *length;
|
||||
@ -1350,6 +1358,13 @@ _fs_md_rename_file(struct spdk_fs_request *req)
|
||||
|
||||
free(f->name);
|
||||
f->name = strdup(args->op.rename.new_name);
|
||||
if (!f->name) {
|
||||
SPDK_ERRLOG("Cannot allocate memory for file name\n");
|
||||
args->fn.fs_op(args->arg, -ENOMEM);
|
||||
free_fs_request(req);
|
||||
return;
|
||||
}
|
||||
|
||||
args->file = f;
|
||||
spdk_bs_open_blob(args->fs->bs, f->blobid, fs_rename_blob_open_cb, req);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user