From 5177ed40c4d2f431114a707f9275da765f84d9d1 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Mon, 17 Jul 2017 14:37:09 -0700 Subject: [PATCH] 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 Reviewed-on: https://review.gerrithub.io/369901 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp --- lib/blobfs/blobfs.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/blobfs/blobfs.c b/lib/blobfs/blobfs.c index 381fa5d54..11c44ace9 100644 --- a/lib/blobfs/blobfs.c +++ b/lib/blobfs/blobfs.c @@ -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; }