From patchwork Fri Jan 7 02:52:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiu Jianfeng X-Patchwork-Id: 12706125 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 2AC46C433EF for ; Fri, 7 Jan 2022 02:51:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345591AbiAGCvn (ORCPT ); Thu, 6 Jan 2022 21:51:43 -0500 Received: from szxga02-in.huawei.com ([45.249.212.188]:17331 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344814AbiAGCvk (ORCPT ); Thu, 6 Jan 2022 21:51:40 -0500 Received: from dggpeml500023.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4JVSQ301Y5z90xm; Fri, 7 Jan 2022 10:50:35 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.58) by dggpeml500023.china.huawei.com (7.185.36.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Fri, 7 Jan 2022 10:51:38 +0800 From: Xiu Jianfeng To: , , , , , , , , , CC: , Subject: [PATCH -next] sched: Use struct_size() helper in task_numa_group() Date: Fri, 7 Jan 2022 10:52:12 +0800 Message-ID: <20220107025212.177040-1-xiujianfeng@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.67.174.58] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500023.china.huawei.com (7.185.36.114) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org Make use of struct_size() helper instead of an open-coded calculation. There is no functional change in this patch. Link: https://github.com/KSPP/linux/issues/160 Signed-off-by: Xiu Jianfeng --- kernel/sched/fair.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 095b0aa378df..265e37be0c92 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2437,11 +2437,8 @@ static void task_numa_group(struct task_struct *p, int cpupid, int flags, int i; if (unlikely(!deref_curr_numa_group(p))) { - unsigned int size = sizeof(struct numa_group) + - NR_NUMA_HINT_FAULT_STATS * - nr_node_ids * sizeof(unsigned long); - - grp = kzalloc(size, GFP_KERNEL | __GFP_NOWARN); + grp = kzalloc(struct_size(grp, faults, NR_NUMA_HINT_FAULT_STATS * nr_node_ids), + GFP_KERNEL | __GFP_NOWARN); if (!grp) return;