提交 38141866 编写于 作者: J Jiankang Chen 提交者: Xie XiuQi

svm: fix some return value and sdma addr error

ascend inclusion
category: feature
bugzilla: 16554
CVE: NA

--------
Signed-off-by: NJiankang Chen <chenjiankang1@huawei.com>
Signed-off-by: NLijun Fang <fanglijun3@huawei.com>
Reviewed-by: NLi Zefan <lizefan@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 77f02fa5
...@@ -177,6 +177,7 @@ void sysrq_sched_debug_show_export(void) ...@@ -177,6 +177,7 @@ void sysrq_sched_debug_show_export(void)
#else #else
pr_err("Not open CONFIG_SCHED_DEBUG\n"); pr_err("Not open CONFIG_SCHED_DEBUG\n");
#endif #endif
panic("pcie heart miss\n");
} }
EXPORT_SYMBOL(sysrq_sched_debug_show_export); EXPORT_SYMBOL(sysrq_sched_debug_show_export);
#endif #endif
...@@ -389,8 +390,8 @@ static int svm_add_sdma(struct svm_process *process, ...@@ -389,8 +390,8 @@ static int svm_add_sdma(struct svm_process *process,
atomic64_set(&sdma->ref, 1); atomic64_set(&sdma->ref, 1);
sdma->addr = addr & PAGE_MASK; sdma->addr = addr & PAGE_MASK;
sdma->nr_pages = (PAGE_ALIGN(size + sdma->addr) >> PAGE_SHIFT) - sdma->nr_pages = (PAGE_ALIGN(size + addr) >> PAGE_SHIFT) -
(addr >> PAGE_SHIFT); (sdma->addr >> PAGE_SHIFT);
sdma->pages = kcalloc(sdma->nr_pages, sizeof(char *), GFP_KERNEL); sdma->pages = kcalloc(sdma->nr_pages, sizeof(char *), GFP_KERNEL);
if (sdma->pages == NULL) { if (sdma->pages == NULL) {
err = -ENOMEM; err = -ENOMEM;
...@@ -485,13 +486,16 @@ static int svm_unpin_memory(unsigned long __user *arg) ...@@ -485,13 +486,16 @@ static int svm_unpin_memory(unsigned long __user *arg)
if (get_user(size, arg + 1)) if (get_user(size, arg + 1))
return -EFAULT; return -EFAULT;
if (ULONG_MAX - addr < size)
return -EINVAL;
asid = mm_context_get(current->mm); asid = mm_context_get(current->mm);
if (!asid) if (!asid)
return -ENOSPC; return -ENOSPC;
addr &= PAGE_MASK; addr &= PAGE_MASK;
nr_pages = (PAGE_ALIGN(size + addr) >> PAGE_SHIFT) - nr_pages = (PAGE_ALIGN(size + addr) >> PAGE_SHIFT) -
(addr >> PAGE_SHIFT); ((addr & PAGE_MASK) >> PAGE_SHIFT);
mutex_lock(&svm_process_mutex); mutex_lock(&svm_process_mutex);
process = find_svm_process(asid); process = find_svm_process(asid);
...@@ -768,6 +772,8 @@ static int svm_process_bind(struct task_struct *task, ...@@ -768,6 +772,8 @@ static int svm_process_bind(struct task_struct *task,
mutex_unlock(&svm_process_mutex); mutex_unlock(&svm_process_mutex);
} else { } else {
mutex_unlock(&svm_process_mutex); mutex_unlock(&svm_process_mutex);
mm_context_put(mm);
put_pid(pid);
} }
...@@ -810,13 +816,13 @@ static int svm_acpi_add_core(struct svm_device *sdev, ...@@ -810,13 +816,13 @@ static int svm_acpi_add_core(struct svm_device *sdev,
cdev->dev.parent = sdev->dev; cdev->dev.parent = sdev->dev;
cdev->dev.bus = &svm_bus_type; cdev->dev.bus = &svm_bus_type;
cdev->dev.release = cdev_device_release; cdev->dev.release = cdev_device_release;
cdev->smmu_bypass = 0;
list_add(&cdev->entry, &child_list); list_add(&cdev->entry, &child_list);
dev_set_name(&cdev->dev, "%s", name); dev_set_name(&cdev->dev, "%s", name);
err = device_register(&cdev->dev); err = device_register(&cdev->dev);
if (err) { if (err) {
dev_info(&cdev->dev, "core_device register failed\n"); dev_info(&cdev->dev, "core_device register failed\n");
put_device(&cdev->dev);
list_del(&cdev->entry); list_del(&cdev->entry);
kfree(cdev); kfree(cdev);
return err; return err;
...@@ -826,7 +832,7 @@ static int svm_acpi_add_core(struct svm_device *sdev, ...@@ -826,7 +832,7 @@ static int svm_acpi_add_core(struct svm_device *sdev,
if (attr != DEV_DMA_NOT_SUPPORTED) { if (attr != DEV_DMA_NOT_SUPPORTED) {
err = acpi_dma_configure(&cdev->dev, attr); err = acpi_dma_configure(&cdev->dev, attr);
if (err) { if (err) {
dev_dbg(&cdev->dev, "of_dma_configure failed\n"); dev_dbg(&cdev->dev, "acpi_dma_configure failed\n");
goto err_unregister_dev; goto err_unregister_dev;
} }
} }
...@@ -835,7 +841,6 @@ static int svm_acpi_add_core(struct svm_device *sdev, ...@@ -835,7 +841,6 @@ static int svm_acpi_add_core(struct svm_device *sdev,
DEV_PROP_U8, &cdev->smmu_bypass); DEV_PROP_U8, &cdev->smmu_bypass);
if (err) { if (err) {
dev_info(&children->dev, "read smmu bypass failed\n"); dev_info(&children->dev, "read smmu bypass failed\n");
goto err_unregister_dev;
} }
cdev->group = iommu_group_get(&cdev->dev); cdev->group = iommu_group_get(&cdev->dev);
...@@ -950,7 +955,6 @@ static int svm_of_add_core(struct svm_device *sdev, struct device_node *np) ...@@ -950,7 +955,6 @@ static int svm_of_add_core(struct svm_device *sdev, struct device_node *np)
err = device_register(&cdev->dev); err = device_register(&cdev->dev);
if (err) { if (err) {
dev_info(&cdev->dev, "core_device register failed\n"); dev_info(&cdev->dev, "core_device register failed\n");
put_device(&cdev->dev);
kfree(cdev); kfree(cdev);
return err; return err;
} }
...@@ -1310,6 +1314,8 @@ static int svm_get_l2pte_base(struct svm_device *sdev, ...@@ -1310,6 +1314,8 @@ static int svm_get_l2pte_base(struct svm_device *sdev,
/* lint !e647 */ /* lint !e647 */
err = copy_to_user((void __user *)arg, base, i * sizeof(*base)); err = copy_to_user((void __user *)arg, base, i * sizeof(*base));
if (err)
err = -EFAULT;
err_out: err_out:
kfree(base); kfree(base);
return err; return err;
...@@ -1317,12 +1323,11 @@ static int svm_get_l2pte_base(struct svm_device *sdev, ...@@ -1317,12 +1323,11 @@ static int svm_get_l2pte_base(struct svm_device *sdev,
static long svm_get_hugeinfo(unsigned long __user *arg) static long svm_get_hugeinfo(unsigned long __user *arg)
{ {
long err = -EINVAL;
struct hstate *h = &default_hstate; struct hstate *h = &default_hstate;
struct meminfo info; struct meminfo info;
if (arg == NULL) if (arg == NULL)
return err; return -EINVAL;
if (!hugepages_supported()) if (!hugepages_supported())
return -ENOTSUPP; return -ENOTSUPP;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册