bdev/virtio: fix memleak in construct_virtio_user_blk_bdev

Fixes #305

Change-Id: I70843e63c74761e71cbe39369249cfa1123a4275
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/411959
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Dariusz Stojaczyk 2018-05-22 04:04:28 +02:00 committed by Daniel Verkamp
parent b0cfbb4fc0
commit 267318d671

View File

@ -331,11 +331,13 @@ spdk_rpc_create_virtio_user_blk_bdev(struct spdk_jsonrpc_request *request,
if (spdk_json_decode_object(params, rpc_construct_virtio_user_blk_dev,
SPDK_COUNTOF(rpc_construct_virtio_user_blk_dev),
&req)) {
free_rpc_construct_virtio_blk_dev(&req);
rc = -EINVAL;
goto invalid;
}
bdev = bdev_virtio_user_blk_dev_create(req.name, req.path, req.vq_count, req.vq_size);
free_rpc_construct_virtio_blk_dev(&req);
if (bdev == NULL) {
rc = -EINVAL;
goto invalid;
@ -355,7 +357,6 @@ spdk_rpc_create_virtio_user_blk_bdev(struct spdk_jsonrpc_request *request,
invalid:
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
spdk_strerror(-rc));
free_rpc_construct_virtio_blk_dev(&req);
}
SPDK_RPC_REGISTER("construct_virtio_user_blk_bdev", spdk_rpc_create_virtio_user_blk_bdev,
SPDK_RPC_RUNTIME);