spdk_top: check thread ID before invoking pop-up from core pop-up

This is to prevent app crashing when selecting a core with no
threads and invoking threads pop-up. The thread ID is being checked
before threads pop-up is displayed.
(by default this value is set to 0, because valid thread IDs start
from the value of 1).

Fixes #2132

Change-Id: I2285370a41fa087c21f968d13882ad06e6577423
Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9363
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Chengqiang Meng <chengqiangx.meng@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Krzysztof Karas 2021-09-01 11:52:06 +00:00 committed by Tomasz Zawadzki
parent e90a98ed98
commit 90a7a92456

View File

@ -2068,7 +2068,7 @@ show_core(uint8_t current_page)
uint64_t core_number = current_page * g_max_data_rows + g_selected_row;
struct rpc_core_info *core_info = &g_cores_info[core_number];
uint64_t threads_count, i;
uint64_t thread_id;
uint64_t thread_id = 0;
uint16_t current_threads_row;
int c;
char core_win_title[25];
@ -2166,9 +2166,13 @@ show_core(uint8_t current_page)
switch (c) {
case 10: /* ENTER */
pthread_mutex_lock(&g_thread_lock);
if (core_info->threads.threads_count > 0) {
thread_id = core_info->threads.thread[current_threads_row].id;
}
pthread_mutex_unlock(&g_thread_lock);
if (thread_id != 0) {
show_single_thread(thread_id);
}
break;
case 27: /* ESC */
stop_loop = true;