[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220605035557.3957759-3-chenwandun@huawei.com>
Date: Sun, 5 Jun 2022 11:55:56 +0800
From: Chen Wandun <chenwandun@...wei.com>
To: <hughd@...gle.com>, <akpm@...ux-foundation.org>,
<linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>,
<willy@...radead.org>, <david@...hat.com>,
<wangkefeng.wang@...wei.com>
Subject: [PATCH v2 2/3] mm/shmem: return error code directly for invalid addr
Return error code directly for addr is not PAGE_SIZE aligned or
beyond TASK_SIZE, no need to check these cases in caller.
Signed-off-by: Chen Wandun <chenwandun@...wei.com>
---
mm/shmem.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mm/shmem.c b/mm/shmem.c
index 17f8297ece29..5e61692f2d8e 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2142,10 +2142,10 @@ unsigned long shmem_get_unmapped_area(struct file *file,
return addr;
if (IS_ERR_VALUE(addr))
return addr;
- if (addr & ~PAGE_MASK)
- return addr;
+ if (offset_in_page(addr))
+ return -EINVAL;
if (addr > TASK_SIZE - len)
- return addr;
+ return -ENOMEM;
if (shmem_huge == SHMEM_HUGE_DENY)
return addr;
@@ -2196,7 +2196,7 @@ unsigned long shmem_get_unmapped_area(struct file *file,
inflated_addr = get_area(NULL, uaddr, inflated_len, 0, flags);
if (IS_ERR_VALUE(inflated_addr))
return addr;
- if (inflated_addr & ~PAGE_MASK)
+ if (offset_in_page(inflated_addr))
return addr;
inflated_offset = inflated_addr & (HPAGE_PMD_SIZE-1);
--
2.25.1
Powered by blists - more mailing lists