event/app_rpc: Fix segmenation fault for scheduler is NULL.

Json writes this scheduler name using pointer, but it sometimes be null.
This case it exists, so add check for it.

Fixes issue #2384

Signed-off-by: Dong Yi <dongx.yi@intel.com>
Change-Id: I7c989c72cfbd53ea6b02d86457b29440484e5a37
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11677
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Dong Yi 2022-02-21 12:36:33 +08:00 committed by Jim Harris
parent 21284e6c74
commit be74ac158c

View File

@ -528,7 +528,9 @@ rpc_framework_get_scheduler(struct spdk_jsonrpc_request *request,
w = spdk_jsonrpc_begin_result(request);
spdk_json_write_object_begin(w);
spdk_json_write_named_string(w, "scheduler_name", scheduler->name);
if (scheduler) {
spdk_json_write_named_string(w, "scheduler_name", scheduler->name);
}
spdk_json_write_named_uint64(w, "scheduler_period", scheduler_period);
if (governor != NULL) {
spdk_json_write_named_string(w, "governor_name", governor->name);