diff mbox series

[3/4] mm/shmem: return error code directly

Message ID 20220601124417.2872001-4-chenwandun@huawei.com (mailing list archive)
State New
Headers show
Series a few cleanup and bugfixes about shmem | expand

Commit Message

Chen Wandun June 1, 2022, 12:44 p.m. UTC
If [addr, addr + len) beyond TASK_SIZE, return error code directly.
No need to check this case in caller.

Signed-off-by: Chen Wandun <chenwandun@huawei.com>
---
 mm/shmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/mm/shmem.c b/mm/shmem.c
index 1136dd7da9e5..ca04f3975a8a 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2146,7 +2146,7 @@  unsigned long shmem_get_unmapped_area(struct file *file,
 	if (offset_in_page(addr))
 		return -EINVAL;
 	if (addr > TASK_SIZE - len)
-		return addr;
+		return -ENOMEM;
 
 	if (shmem_huge == SHMEM_HUGE_DENY)
 		return addr;