sock: Fix memory leak in RPC

Memory allocated for impl_name is not freed in error cases.

Signed-off-by: Alexey Marchuk <alexeymar@mellanox.com>
Change-Id: If7cd62d948a05421b0bd5d1599f1275a0f3b4597
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4330
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Alexey Marchuk 2020-09-21 17:56:10 +03:00 committed by Tomasz Zawadzki
parent 8614d3fe3a
commit 43773a5a3a

View File

@ -143,6 +143,7 @@ rpc_sock_impl_set_options(struct spdk_jsonrpc_request *request,
len = sizeof(opts.sock_opts);
rc = spdk_sock_impl_get_opts(opts.impl_name, &opts.sock_opts, &len);
if (rc) {
free(opts.impl_name);
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
"Invalid parameters");
return;
@ -159,6 +160,7 @@ rpc_sock_impl_set_options(struct spdk_jsonrpc_request *request,
rc = spdk_sock_impl_set_opts(opts.impl_name, &opts.sock_opts, sizeof(opts.sock_opts));
if (rc != 0) {
free(opts.impl_name);
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
"Invalid parameters");
return;