bdev/virtio/rpc: fix memleak in construct_virtio_pci_blk_bdev RPC
Fixes #311 Change-Id: I9fff0dd3b0a1a564355af7fbc0f700f680602ac5 Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/412548 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Pawel Kaminski <pawelx.kaminski@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
266f37a5a0
commit
a3c9b23b84
@ -381,17 +381,20 @@ spdk_rpc_create_virtio_pci_blk_bdev(struct spdk_jsonrpc_request *request,
|
||||
if (spdk_json_decode_object(params, rpc_construct_virtio_pci_blk_dev,
|
||||
SPDK_COUNTOF(rpc_construct_virtio_pci_blk_dev),
|
||||
&req)) {
|
||||
free_rpc_construct_virtio_blk_dev(&req);
|
||||
rc = -EINVAL;
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
if (spdk_pci_addr_parse(&pci_addr, req.pci_address) != 0) {
|
||||
SPDK_ERRLOG("Invalid PCI address '%s'\n", req.pci_address);
|
||||
free_rpc_construct_virtio_blk_dev(&req);
|
||||
rc = -EINVAL;
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
bdev = bdev_virtio_pci_blk_dev_create(req.name, &pci_addr);
|
||||
free_rpc_construct_virtio_blk_dev(&req);
|
||||
if (bdev == NULL) {
|
||||
rc = -EINVAL;
|
||||
goto invalid;
|
||||
@ -411,7 +414,6 @@ spdk_rpc_create_virtio_pci_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_pci_blk_bdev", spdk_rpc_create_virtio_pci_blk_bdev,
|
||||
SPDK_RPC_RUNTIME);
|
||||
|
Loading…
x
Reference in New Issue
Block a user