diff --git a/executer/kernel/mcctrl/control.c b/executer/kernel/mcctrl/control.c index b22c2da3..22cc5d27 100644 --- a/executer/kernel/mcctrl/control.c +++ b/executer/kernel/mcctrl/control.c @@ -2290,20 +2290,30 @@ long mcctrl_perf_set(ihk_os_t os, struct ihk_perf_event_attr *__user arg) long mcctrl_perf_get(ihk_os_t os, unsigned long *__user arg) { - struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os); + struct mcctrl_usrdata *usrdata = NULL; struct ikc_scd_packet isp; struct perf_ctrl_desc *perf_desc; - struct ihk_cpu_info *info = ihk_os_get_cpu_info(os); + struct ihk_cpu_info *info = NULL; unsigned long value_sum = 0; int ret = 0; int i = 0, j = 0; int need_free; + if (!os || ihk_host_validate_os(os)) { + return -EINVAL; + } + + usrdata = ihk_host_os_get_usrdata(os); if (!usrdata) { pr_err("%s: error: mcctrl_usrdata not found\n", __func__); return -EINVAL; } + info = ihk_os_get_cpu_info(os); + if (!info || info->n_cpus < 1) { + return -EINVAL; + } + for (i = 0; i < usrdata->perf_event_num; i++) { perf_desc = kmalloc(sizeof(struct mcctrl_perf_ctrl_desc), GFP_KERNEL);