提交 83b74112 编写于 作者: J Jialin Zhang 提交者: Zheng Zengkai

arm64/mpam: update last_cmd_status in parse_cache() and parse_bw()

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I61CPK
CVE: NA

--------------------------------

Update last_cmd_status to tell the reasons of returning 'Invalid argument'
in parse_cache() and parse_bw().
Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com>
Signed-off-by: NWang ShaoBo <bobo.shaobowang@huawei.com>
Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 01a2ee3e
......@@ -310,11 +310,15 @@ parse_cache(char *buf, struct resctrl_resource *r,
return -EINVAL;
}
if (kstrtoul(buf, rr->ctrl_features[type].base, &data))
if (kstrtoul(buf, rr->ctrl_features[type].base, &data)) {
rdt_last_cmd_printf("Non-hex character in the mask %s\n", buf);
return -EINVAL;
}
if (data >= rr->ctrl_features[type].max_wd)
if (data >= rr->ctrl_features[type].max_wd) {
rdt_last_cmd_puts("Mask out of range\n");
return -EINVAL;
}
cfg->new_ctrl[type] = data;
cfg->have_new_ctrl = true;
......@@ -339,20 +343,30 @@ parse_bw(char *buf, struct resctrl_resource *r,
case QOS_MBA_MAX_EVENT_ID:
case QOS_MBA_PBM_EVENT_ID:
case QOS_MBA_MIN_EVENT_ID:
if (kstrtoul(buf, rr->ctrl_features[type].base, &data))
if (kstrtoul(buf, rr->ctrl_features[type].base, &data)) {
rdt_last_cmd_printf("Non-decimal digit in MB value %s\n", buf);
return -EINVAL;
if (data < r->mbw.min_bw)
}
if (data < r->mbw.min_bw) {
rdt_last_cmd_printf("MB value %ld out of range [%d,%d]\n", data,
r->mbw.min_bw, rr->ctrl_features[type].max_wd - 1);
return -EINVAL;
}
data = roundup(data, r->mbw.bw_gran);
break;
default:
if (kstrtoul(buf, rr->ctrl_features[type].base, &data))
if (kstrtoul(buf, rr->ctrl_features[type].base, &data)) {
rdt_last_cmd_printf("Non-decimal digit in MB value %s\n", buf);
return -EINVAL;
}
break;
}
if (data >= rr->ctrl_features[type].max_wd)
if (data >= rr->ctrl_features[type].max_wd) {
rdt_last_cmd_printf("MB value %ld out of range [%d,%d]\n", data,
r->mbw.min_bw, rr->ctrl_features[type].max_wd - 1);
return -EINVAL;
}
cfg->new_ctrl[type] = data;
cfg->have_new_ctrl = true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册