From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EC8CC433F5 for ; Wed, 1 Jun 2022 12:23:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239274AbiFAMXg (ORCPT ); Wed, 1 Jun 2022 08:23:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241237AbiFAMX1 (ORCPT ); Wed, 1 Jun 2022 08:23:27 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 265FA3A71C for ; Wed, 1 Jun 2022 05:23:27 -0700 (PDT) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LCpF718ZWzjXHt; Wed, 1 Jun 2022 20:22:35 +0800 (CST) Received: from dggpemm500002.china.huawei.com (7.185.36.229) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 1 Jun 2022 20:23:25 +0800 Received: from localhost.localdomain (10.175.112.125) by dggpemm500002.china.huawei.com (7.185.36.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 1 Jun 2022 20:23:25 +0800 From: Chen Wandun To: , , , CC: Subject: [PATCH 3/4] mm/shmem: return error code directly Date: Wed, 1 Jun 2022 20:44:16 +0800 Message-ID: <20220601124417.2872001-4-chenwandun@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220601124417.2872001-1-chenwandun@huawei.com> References: <20220601124417.2872001-1-chenwandun@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500002.china.huawei.com (7.185.36.229) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If [addr, addr + len) beyond TASK_SIZE, return error code directly. No need to check this case in caller. Signed-off-by: Chen Wandun --- mm/shmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.25.1