Commit 57eee182 authored by yidong0635's avatar yidong0635 Committed by Tomasz Zawadzki
Browse files

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: default avataryidong0635 <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: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent ebf077cb
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -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);
}