
From: Tang Yizhou <tangyizhou@huawei.com> ascend inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I4EUVI CVE: NA ------------------------------------------------- v2: Fix a compilation warning. 1. Set errno when fail in sp_free() 2. Remove redundant deassociation of uva and kva in sp_unshare_kva(). One of the reason is that this code allows vmalloc + k2u + unshare kva to be legal. Signed-off-by: Tang Yizhou <tangyizhou@huawei.com> Reviewed-by: Ding Tianhong <dingtianhong@huawei.com> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Reviewed-by: Weilong Chen <chenweilong@huawei.com> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> --- mm/share_pool.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/mm/share_pool.c b/mm/share_pool.c index 1370e656320f2..b36d336b21656 100644 --- a/mm/share_pool.c +++ b/mm/share_pool.c @@ -895,6 +895,7 @@ static struct sp_area *sp_alloc_area(unsigned long size, unsigned long flags, atomic_set(&spa->use_count, 1); spa->type = type; spa->mm = NULL; + spa->kva = 0; /* NULL pointer */ if (spa_inc_usage(type, size, (flags & SP_DVPP))) { err = ERR_PTR(-EINVAL); @@ -1105,6 +1106,7 @@ int sp_free(unsigned long addr) } if (spa->type != SPA_TYPE_ALLOC) { + ret = -EINVAL; if (printk_ratelimit()) pr_err("share pool: sp free failed, addr %pK is not from sp_alloc\n", (void *)addr); @@ -2062,7 +2064,6 @@ static int sp_unshare_kva(unsigned long kva, unsigned long size) unsigned long step; bool is_hugepage = true; int ret; - struct vm_struct *area; ret = is_vmap_hugepage(kva); if (ret > 0) { @@ -2098,11 +2099,6 @@ static int sp_unshare_kva(unsigned long kva, unsigned long size) (void *)addr); } - /* deassociate vma and spa */ - area = find_vm_area((void *)kva_aligned); - if (area) - area->flags &= ~VM_SHAREPOOL; - vunmap((void *)kva_aligned); return 0; -- 2.25.1