blobfs: Handle request alloc failure during init/load

If the spdk_filesystem object is created but the initial
request allocation fails, correctly clean up. This
addresses a static analysis failure.

Change-Id: If47a380d8804a279ec92d2aee3de7d86bb5c67fa
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/369901
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Ben Walker 2017-07-17 14:37:09 -07:00 committed by Daniel Verkamp
parent fe84b2eb02
commit 5177ed40c4

View File

@ -439,6 +439,12 @@ spdk_fs_init(struct spdk_bs_dev *dev, fs_send_request_fn send_request_fn,
req = alloc_fs_request(fs->md_target.md_fs_channel);
if (req == NULL) {
spdk_put_io_channel(fs->md_target.md_io_channel);
spdk_io_device_unregister(&fs->md_target);
spdk_put_io_channel(fs->sync_target.sync_io_channel);
spdk_io_device_unregister(&fs->sync_target);
spdk_io_device_unregister(&fs->io_target);
free(fs);
cb_fn(cb_arg, NULL, -ENOMEM);
return;
}
@ -559,6 +565,12 @@ spdk_fs_load(struct spdk_bs_dev *dev, fs_send_request_fn send_request_fn,
req = alloc_fs_request(fs->md_target.md_fs_channel);
if (req == NULL) {
spdk_put_io_channel(fs->md_target.md_io_channel);
spdk_io_device_unregister(&fs->md_target);
spdk_put_io_channel(fs->sync_target.sync_io_channel);
spdk_io_device_unregister(&fs->sync_target);
spdk_io_device_unregister(&fs->io_target);
free(fs);
cb_fn(cb_arg, NULL, -ENOMEM);
return;
}