diff --git a/lib/blob/blobstore.c b/lib/blob/blobstore.c index 995c1a9d5..b3917a5c7 100644 --- a/lib/blob/blobstore.c +++ b/lib/blob/blobstore.c @@ -2825,12 +2825,14 @@ spdk_bs_load(struct spdk_bs_dev *dev, struct spdk_bs_opts *o, } if (opts.max_md_ops == 0 || opts.max_channel_ops == 0) { + dev->destroy(dev); cb_fn(cb_arg, NULL, -EINVAL); return; } bs = _spdk_bs_alloc(dev, &opts); if (!bs) { + dev->destroy(dev); cb_fn(cb_arg, NULL, -ENOMEM); return; } diff --git a/test/unit/lib/blob/blob.c/blob_ut.c b/test/unit/lib/blob/blob.c/blob_ut.c index f803cd574..af58e2441 100644 --- a/test/unit/lib/blob/blob.c/blob_ut.c +++ b/test/unit/lib/blob/blob.c/blob_ut.c @@ -1547,8 +1547,23 @@ bs_load(void) spdk_bs_load(dev, NULL, bs_op_with_handle_complete, NULL); CU_ASSERT(g_bserrno == -EINVAL); + /* Load should when max_md_ops is set to zero */ + dev = init_dev(); + spdk_bs_opts_init(&opts); + opts.max_md_ops = 0; + spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + CU_ASSERT(g_bserrno == -EINVAL); + + /* Load should when max_channel_ops is set to zero */ + dev = init_dev(); + spdk_bs_opts_init(&opts); + opts.max_channel_ops = 0; + spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + CU_ASSERT(g_bserrno == -EINVAL); + /* Load an existing blob store */ dev = init_dev(); + spdk_bs_opts_init(&opts); strncpy(opts.bstype.bstype, "TESTTYPE", SPDK_BLOBSTORE_TYPE_LENGTH); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); CU_ASSERT(g_bserrno == 0);