Commit 2ef4855e authored by Zhiqiang Liu's avatar Zhiqiang Liu Committed by Tomasz Zawadzki
Browse files

blobfs: check return value of strdup in spdk_fs_create_file_async()



In spdk_fs_create_file_async(), file->name is set to strdup(name).
We should check whether file->name is equal to NULL.

Signed-off-by: default avatarZhiqiang Liu <liuzhiqiang26@huawei.com>
Change-Id: I2219cc353eb4711290aee2599505f57af9088bb2
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8302


Community-CI: Mellanox Build Bot
Reviewed-by: default avatarZiye Yang <ziye.yang@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent d491e7ea
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1100,6 +1100,8 @@ spdk_fs_create_file_async(struct spdk_filesystem *fs, const char *name,
	req = alloc_fs_request(fs->md_target.md_fs_channel);
	if (req == NULL) {
		SPDK_ERRLOG("Cannot allocate create async req for file=%s\n", name);
		TAILQ_REMOVE(&fs->files, file, tailq);
		file_free(file);
		cb_fn(cb_arg, -ENOMEM);
		return;
	}
@@ -1110,6 +1112,14 @@ spdk_fs_create_file_async(struct spdk_filesystem *fs, const char *name,
	args->arg = cb_arg;

	file->name = strdup(name);
	if (!file->name) {
		SPDK_ERRLOG("Cannot allocate file->name for file=%s\n", name);
		free_fs_request(req);
		TAILQ_REMOVE(&fs->files, file, tailq);
		file_free(file);
		cb_fn(cb_arg, -ENOMEM);
		return;
	}
	_file_build_trace_arg_name(file);
	spdk_bs_create_blob(fs->bs, fs_create_blob_create_cb, args);
}