提交 fede753a 编写于 作者: H Hao Fang 提交者: Xie XiuQi

ACC: crypto/hisilicon/zip: add zip module param uacce_mode valid check

driver inclusion
category: bugfix
bugzilla: NA
CVE: NA

uacce_mode only support 0/1/2, other option is invalid.
Signed-off-by: NHao Fang <fanghao11@huawei.com>
Reviewed-by: Nwangzhou <wangzhou1@hisilicon.com>
Signed-off-by: Nlingmingqiang <lingmingqiang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 3b1df238
...@@ -92,6 +92,7 @@ ...@@ -92,6 +92,7 @@
#define HZIP_NUMA_DISTANCE 100 #define HZIP_NUMA_DISTANCE 100
#define HZIP_BUF_SIZE 20 #define HZIP_BUF_SIZE 20
#define FORMAT_DECIMAL 10
static const char hisi_zip_name[] = "hisi_zip"; static const char hisi_zip_name[] = "hisi_zip";
static struct dentry *hzip_debugfs_root; static struct dentry *hzip_debugfs_root;
...@@ -304,13 +305,33 @@ static const struct kernel_param_ops pf_q_num_ops = { ...@@ -304,13 +305,33 @@ static const struct kernel_param_ops pf_q_num_ops = {
.set = pf_q_num_set, .set = pf_q_num_set,
.get = param_get_int, .get = param_get_int,
}; };
static int uacce_mode_set(const char *val, const struct kernel_param *kp)
{
u32 n;
int ret;
if (!val)
return -EINVAL;
ret = kstrtou32(val, FORMAT_DECIMAL, &n);
if (ret != 0 || n > UACCE_MODE_NOIOMMU)
return -EINVAL;
return param_set_int(val, kp);
}
static const struct kernel_param_ops uacce_mode_ops = {
.set = uacce_mode_set,
.get = param_get_int,
};
static u32 pf_q_num = HZIP_PF_DEF_Q_NUM; static u32 pf_q_num = HZIP_PF_DEF_Q_NUM;
module_param_cb(pf_q_num, &pf_q_num_ops, &pf_q_num, 0444); module_param_cb(pf_q_num, &pf_q_num_ops, &pf_q_num, 0444);
MODULE_PARM_DESC(pf_q_num, "Number of queues in PF(v1 1-4096, v2 1-1024)"); MODULE_PARM_DESC(pf_q_num, "Number of queues in PF(v1 1-4096, v2 1-1024)");
static int uacce_mode = UACCE_MODE_NOUACCE; static int uacce_mode = UACCE_MODE_NOUACCE;
module_param(uacce_mode, int, 0444); module_param_cb(uacce_mode, &uacce_mode_ops, &uacce_mode, 0444);
MODULE_PARM_DESC(uacce_mode, "Mode of UACCE can be 0(default), 1, 2");
static const struct pci_device_id hisi_zip_dev_ids[] = { static const struct pci_device_id hisi_zip_dev_ids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_HUAWEI, PCI_DEVICE_ID_ZIP_PF) }, { PCI_DEVICE(PCI_VENDOR_ID_HUAWEI, PCI_DEVICE_ID_ZIP_PF) },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册