mcctrl_perf_set : validate os input & check cpu info
Change-Id: If308013746ff6dce03fa8e0eb1ebaca1cb2a4a64
This commit is contained in:
committed by
Masamichi Takagi
parent
8c0b2ab6ce
commit
550c6cc5fb
@@ -2203,22 +2203,34 @@ struct mcctrl_perf_ctrl_desc {
|
|||||||
*/
|
*/
|
||||||
long mcctrl_perf_set(ihk_os_t os, struct ihk_perf_event_attr *__user arg)
|
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 ikc_scd_packet isp;
|
||||||
struct perf_ctrl_desc *perf_desc;
|
struct perf_ctrl_desc *perf_desc;
|
||||||
struct ihk_perf_event_attr attr;
|
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 ret = 0;
|
||||||
int i = 0, j = 0;
|
int i = 0, j = 0;
|
||||||
int need_free;
|
int need_free;
|
||||||
int num_registered = 0;
|
int num_registered = 0;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
|
if (!os || ihk_host_validate_os(os)) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
usrdata = ihk_host_os_get_usrdata(os);
|
||||||
|
|
||||||
if (!usrdata) {
|
if (!usrdata) {
|
||||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||||
return -EINVAL;
|
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++) {
|
for (i = 0; i < usrdata->perf_event_num; i++) {
|
||||||
ret = copy_from_user(&attr, &arg[i],
|
ret = copy_from_user(&attr, &arg[i],
|
||||||
sizeof(struct ihk_perf_event_attr));
|
sizeof(struct ihk_perf_event_attr));
|
||||||
|
|||||||
Reference in New Issue
Block a user