app/spdk_top: check the valid pointer earlier
Change-Id: I162d90257e7bf23cff9b9adc84b811f79c404da2 Signed-off-by: GangCao <gang.cao@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16178 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
544a8fe597
commit
3ecf99d65a
@ -488,11 +488,8 @@ rpc_decode_cores_lw_threads(const struct spdk_json_val *val, void *out)
|
|||||||
* 'val' value (-2 is to subtract VAL_OBJECT_BEGIN/END). */
|
* 'val' value (-2 is to subtract VAL_OBJECT_BEGIN/END). */
|
||||||
uint16_t threads_count = (spdk_json_val_len(val) - 2) / RPC_THREAD_ENTRY_SIZE;
|
uint16_t threads_count = (spdk_json_val_len(val) - 2) / RPC_THREAD_ENTRY_SIZE;
|
||||||
|
|
||||||
|
assert(threads != NULL);
|
||||||
threads->thread = calloc(threads_count, sizeof(struct rpc_core_thread_info));
|
threads->thread = calloc(threads_count, sizeof(struct rpc_core_thread_info));
|
||||||
if (!out) {
|
|
||||||
fprintf(stderr, "Unable to allocate memory for a thread array.\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return spdk_json_decode_array(val, rpc_decode_core_threads_object, threads->thread, threads_count,
|
return spdk_json_decode_array(val, rpc_decode_core_threads_object, threads->thread, threads_count,
|
||||||
&threads->threads_count, sizeof(struct rpc_core_thread_info));
|
&threads->threads_count, sizeof(struct rpc_core_thread_info));
|
||||||
|
Loading…
Reference in New Issue
Block a user