From nobody Mon Apr 6 06:31:11 2026 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 5F5ECECAAD3 for ; Fri, 9 Sep 2022 10:10:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230170AbiIIKKt (ORCPT ); Fri, 9 Sep 2022 06:10:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230090AbiIIKKd (ORCPT ); Fri, 9 Sep 2022 06:10:33 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E8E19A6A7 for ; Fri, 9 Sep 2022 03:10:31 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id f24so1348061plr.1 for ; Fri, 09 Sep 2022 03:10:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=Uu8/Y7CXXBHRNAqM/p4WezJYKvf+VwWvJUdWkJfyMKo=; b=KkyxGz1900lycU6F64B1E5AGOyGFi9NaUG/1QGhRXkEnya90K3ATDXi/QwnFauVwsh 2kalkbOwpmu8FwpDQRx3Qk8hmPNSeqNL6bK1WokhhHqCvClPjW8AKgJY6i0uoucARmQj N+Dh1O+uvpEQ2R/kF8zluGF4JMnhUOxmMLNecZmPtST5aqgAt3R5LkWbnIAF4V3La7S0 3PbkiXnblk7DP9oSmwfo8H+PHYfvr40kppotFzvKf7I4dIWYmMwht+8Zx/rTYJLQMcYS LnXGGJ9Ih3GXR9ZUBHNP19U/vlzzm4VZCSY0AkOCMw8NYPAHkQLN+dm/E5KfOiDsade2 rKnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=Uu8/Y7CXXBHRNAqM/p4WezJYKvf+VwWvJUdWkJfyMKo=; b=EcCHQTFg1LAYPCar3fUtcStgC72kp5XyaQhng9ImaXC10Qop6cT7JJK9jJE+8yuRsR fFh1kjC1hm1Fh1rHV24dQvzJ7KidxAhCf4ZQZ54aUqVTysXbqbZPHZ8yGfDXX+XgJfxy j0jlAKkD8/qYB4AyMZI64CBYteFlIFwLnwlGfES6mJ3geUJaGZwmjrbob5hb4Yavakr9 1gfxJOCxALqt5SXhypKat7/TqJI8RcXbAzmeqoYZV9aklZxVLaax4q8C1/3tf3vfTvW9 wYfpEjaTcw1H3pXcE+qqBW8d9nb61jcXv5Gret6UOgemCXOtRSicbNcr9EUqvu66TMZn aDFg== X-Gm-Message-State: ACgBeo0D9eEmgkIiiGO+eCK2RKVIXx9UWkaXPRF6JQ0uzJRhn9YIb/ah /vviu26ox58GzA6DLjM48EmOyofGyxk= X-Google-Smtp-Source: AA6agR5GRcLHupA/O/ATwASHpZ3W7F7CXeIy2G8uy7pg2Jhd4zriysokpuJwLhFMn90IsyKSTmj/qA== X-Received: by 2002:a17:90b:350b:b0:202:8495:6275 with SMTP id ls11-20020a17090b350b00b0020284956275mr4081802pjb.216.1662718230775; Fri, 09 Sep 2022 03:10:30 -0700 (PDT) Received: from C02FG34WMD6R.bytedance.net ([139.177.225.235]) by smtp.gmail.com with ESMTPSA id o10-20020a62cd0a000000b00537d0207b30sm107469pfg.184.2022.09.09.03.10.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 03:10:30 -0700 (PDT) From: wuchi To: hch@lst.de, axboe@kernel.dk, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH] relay: use kvcalloc to alloc page array in relay_alloc_page_array Date: Fri, 9 Sep 2022 18:10:25 +0800 Message-Id: <20220909101025.82955-1-wuchi.zero@gmail.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The kvcalloc is safer because it will check the integer overflows, and using it will simple the logic of allocation size. Signed-off-by: wuchi --- kernel/relay.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/kernel/relay.c b/kernel/relay.c index 6a611e779e95..d7edc934c56d 100644 --- a/kernel/relay.c +++ b/kernel/relay.c @@ -60,10 +60,7 @@ static const struct vm_operations_struct relay_file_mmap= _ops =3D { */ static struct page **relay_alloc_page_array(unsigned int n_pages) { - const size_t pa_size =3D n_pages * sizeof(struct page *); - if (pa_size > PAGE_SIZE) - return vzalloc(pa_size); - return kzalloc(pa_size, GFP_KERNEL); + return kvcalloc(n_pages, sizeof(struct page *), GFP_KERNEL); } =20 /* --=20 2.20.1