Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp612393pxk; Thu, 1 Oct 2020 10:02:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvxxKpueVmqUiPO6WEIkzAYsogoOJszVXKynROkDrD9Uxnwz9IlSN4Gvy8NIkCa3FUFglu X-Received: by 2002:a05:6402:14d4:: with SMTP id f20mr8972031edx.291.1601571742071; Thu, 01 Oct 2020 10:02:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601571742; cv=none; d=google.com; s=arc-20160816; b=rXWOaouRuZiANyB8N8jGmcpMrtxgrtdYBWbgOmvMudHAcd3bLkZ4/va3fsaclnskh4 UaIHgIe3eAqdaM7dadxkcULOFfIrCyJcAPd2C2R1v8o1rG/AEe7+kVr72QBzu5Vw8+kH graDH1fx1mHhVqFrw44GXZpKOcfw8l7zLRQtLgxRTcUiJJjHInMBvOE+TUkd0JTCb1Ch I2XPHMMLL8qzPmJ9eMNhHqC1Tf4zCZROGUz+Kzoh6KAL8Tf08n4Lv4D4fwxQt3w90ivj 2f30FGhm/XNohvNaQgmej6HjnCJXeba2WOUOFkMvyDbhXXQEggTQF6mYze4eDrPPFNiH PEvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=h2viArEXynjFH7Vx0/SFoYIVa4IC3HY4Q4jMKRoLIe4=; b=gFyuFQrVKuccNHdebonhKrVIjJV3PmsmowWrQDE48BM+6d5aQSvf4fV0JjE1nCWEYx xnR4oWnw19keHC/wCHO/cy03HsZ2FbyTtPa7lFlqoOxyU1Wpq7UeFDEGagBEzlGFWO6I Pk2xndNRKitzAmfpjTNccKPa+cl27gHP3Lr70PI7MZa2DSt9X2sd3flsqtYN2ftfsXL3 DLizh8ZBVS0zqxABdAkMoPg+/IFgjro56aLY1z+/pmnKkBT8wW2i3Fba6tQViQwgzX5D CGQhtGc6lY/zxGuvscQIwzTaTrCL468PUJlMFJ/7W50SoVrPoSZy2Ghsjlnh4M/ReT/Z TzeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=p5qF1xaQ; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n5si4002462ejk.375.2020.10.01.10.01.50; Thu, 01 Oct 2020 10:02:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=p5qF1xaQ; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732588AbgJAQ7t (ORCPT + 99 others); Thu, 1 Oct 2020 12:59:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732107AbgJAQ7s (ORCPT ); Thu, 1 Oct 2020 12:59:48 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E4FEC0613D0; Thu, 1 Oct 2020 09:59:48 -0700 (PDT) Date: Thu, 01 Oct 2020 16:59:44 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1601571585; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h2viArEXynjFH7Vx0/SFoYIVa4IC3HY4Q4jMKRoLIe4=; b=p5qF1xaQ0fFExDh4PlL9+elXzzstA881bkj8pNbMUibeQ1nhXpZ5vzFsEqwfABsrCZLse8 /UIHvyDkhnIanatDJgQgAOI3ipNF5x3LVcWM181UZnOmjhHd8aIS8spLNzmNwF6KvrdyEx 8FzBzto1oPI79TOECbbTxIxHADU/A3ZHRcOPJa/kG9lt0xHpTLdqPaGC7cghf+JczFjdTn H89R0Lqt5vYaBgOD9HUK6GLhYgzfJFMy52Rxu0YVoDGhvekMGg3ARCwuoHzgl9YYezwFUI G4QToGHPKsbjs8q7yw3B4C+aGj8+xlDp+wKYnFzVBJc6Z0sF6nWdMKc/om7jww== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1601571585; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h2viArEXynjFH7Vx0/SFoYIVa4IC3HY4Q4jMKRoLIe4=; b=mBT75TPfmGGfGcZhlyBvOyLXqAbktZjWg/XF76NYx1wYXIg0XrtsVNLAgj0arIF03ahywt Ax7LRiRrXdWMAMAw== From: "tip-bot2 for Gustavo A. R. Silva" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/platform] x86/uv/time: Use a flexible array in struct uv_rtc_timer_head Cc: "Gustavo A. R. Silva" , Borislav Petkov , Kees Cook , Steve Wahl , x86 , LKML In-Reply-To: <20201001145608.GA10204@embeddedor> References: <20201001145608.GA10204@embeddedor> MIME-Version: 1.0 Message-ID: <160157158480.7002.8851684386361032723.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/platform branch of tip: Commit-ID: a0947081af2ac9549e6ba19877456730713bde23 Gitweb: https://git.kernel.org/tip/a0947081af2ac9549e6ba19877456730713= bde23 Author: Gustavo A. R. Silva AuthorDate: Thu, 01 Oct 2020 09:56:08 -05:00 Committer: Borislav Petkov CommitterDate: Thu, 01 Oct 2020 18:47:39 +02:00 x86/uv/time: Use a flexible array in struct uv_rtc_timer_head There is a regular need in the kernel to provide a way to declare having a dynamically sized set of trailing elements in a structure. Kernel code should always use =E2=80=9Cflexible array members=E2=80=9D[1] for these cases= . The older style of one-element or zero-length arrays should no longer be used[2]. struct uv_rtc_timer_head contains a one-element array cpu[1]. Switch it to a flexible array and use the struct_size() helper to calculate the allocation size. Also, save some heap space in the process[3]. [1] https://en.wikipedia.org/wiki/Flexible_array_member [2] https://www.kernel.org/doc/html/v5.9-rc1/process/deprecated.html#zero-len= gth-and-one-element-arrays [3] https://lore.kernel.org/lkml/20200518190114.GA7757@embeddedor/ [ bp: Massage a bit. ] Signed-off-by: Gustavo A. R. Silva Signed-off-by: Borislav Petkov Reviewed-by: Kees Cook Cc: Steve Wahl Link: https://lkml.kernel.org/r/20201001145608.GA10204@embeddedor --- arch/x86/platform/uv/uv_time.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/x86/platform/uv/uv_time.c b/arch/x86/platform/uv/uv_time.c index f82a133..6c348c2 100644 --- a/arch/x86/platform/uv/uv_time.c +++ b/arch/x86/platform/uv/uv_time.c @@ -52,7 +52,7 @@ struct uv_rtc_timer_head { struct { int lcpu; /* systemwide logical cpu number */ u64 expires; /* next timer expiration for this cpu */ - } cpu[1]; + } cpu[]; }; =20 /* @@ -148,9 +148,8 @@ static __init int uv_rtc_allocate_timers(void) struct uv_rtc_timer_head *head =3D blade_info[bid]; =20 if (!head) { - head =3D kmalloc_node(sizeof(struct uv_rtc_timer_head) + - (uv_blade_nr_possible_cpus(bid) * - 2 * sizeof(u64)), + head =3D kmalloc_node(struct_size(head, cpu, + uv_blade_nr_possible_cpus(bid)), GFP_KERNEL, nid); if (!head) { uv_rtc_deallocate_timers();