bdev/null: fix RPC string memory leak
The uuid string was not freed. Factor out the free() calls into a helper function and add a free of uuid. Change-Id: I2f5f794e240fcdb07f346b892ea4dec46dc9bdb6 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/406665 Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
aa3345346c
commit
415933c879
@ -46,6 +46,13 @@ struct rpc_construct_null {
|
||||
uint32_t block_size;
|
||||
};
|
||||
|
||||
static void
|
||||
free_rpc_construct_null(struct rpc_construct_null *req)
|
||||
{
|
||||
free(req->name);
|
||||
free(req->uuid);
|
||||
}
|
||||
|
||||
static const struct spdk_json_object_decoder rpc_construct_null_decoders[] = {
|
||||
{"name", offsetof(struct rpc_construct_null, name), spdk_json_decode_string},
|
||||
{"uuid", offsetof(struct rpc_construct_null, uuid), spdk_json_decode_string, true},
|
||||
@ -84,7 +91,7 @@ spdk_rpc_construct_null_bdev(struct spdk_jsonrpc_request *request,
|
||||
|
||||
w = spdk_jsonrpc_begin_result(request);
|
||||
if (w == NULL) {
|
||||
free(req.name);
|
||||
free_rpc_construct_null(&req);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -92,11 +99,11 @@ spdk_rpc_construct_null_bdev(struct spdk_jsonrpc_request *request,
|
||||
spdk_json_write_string(w, bdev->name);
|
||||
spdk_json_write_array_end(w);
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
free(req.name);
|
||||
free_rpc_construct_null(&req);
|
||||
return;
|
||||
|
||||
invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free(req.name);
|
||||
free_rpc_construct_null(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("construct_null_bdev", spdk_rpc_construct_null_bdev)
|
||||
|
Loading…
Reference in New Issue
Block a user