diff --git a/executer/kernel/mcctrl/control.c b/executer/kernel/mcctrl/control.c index f36d00ca..782854fe 100644 --- a/executer/kernel/mcctrl/control.c +++ b/executer/kernel/mcctrl/control.c @@ -2203,22 +2203,34 @@ struct mcctrl_perf_ctrl_desc { */ long mcctrl_perf_set(ihk_os_t os, struct ihk_perf_event_attr *__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_perf_event_attr attr; - struct ihk_cpu_info *info = ihk_os_get_cpu_info(os); + struct ihk_cpu_info *info = NULL; int ret = 0; int i = 0, j = 0; int need_free; int num_registered = 0; int err = 0; + 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) { + pr_err("%s: error: cannot get cpu info\n", __func__); + return -EINVAL; + } + for (i = 0; i < usrdata->perf_event_num; i++) { ret = copy_from_user(&attr, &arg[i], sizeof(struct ihk_perf_event_attr));