From nobody Sun Feb 8 17:55:08 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 2D0E6C7EE2D for ; Fri, 19 May 2023 17:42:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230263AbjESRmj (ORCPT ); Fri, 19 May 2023 13:42:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230110AbjESRmh (ORCPT ); Fri, 19 May 2023 13:42:37 -0400 Received: from smtp.smtpout.orange.fr (smtp-30.smtpout.orange.fr [80.12.242.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F5C210F for ; Fri, 19 May 2023 10:42:34 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id 047Zqh2d1ln91047ZqYTB1; Fri, 19 May 2023 19:42:32 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1684518152; bh=mAaO/WBbYiwwJShzEiCb+5IddAiptsLyN04MdP2OqLA=; h=From:To:Cc:Subject:Date; b=H3CtDD3+Pj6GAN5+IziYhhQ43auTun8QEHu+PODCpbpFNWxka/yOMP5BimHMJhh5s lBHmslKC7aU9q4GFO/15SKg9uZWve9BNm75A8VSTMUEOpeNlVcD9fwJAHmExobhQK6 q16gz/LLg4Bhl2UFCVn2BlgX7GiPrxMxFiDwLRduECWS1vfsEC6bah6Aq7KR1X8jr5 TUmXEXfVw51CEGaR39ZYxTzVDnC/3mN02yhJEV98H8zQbRCfa3j+HxSvd0GBYcCLCT APQPim1923PLfgxiJ13Pn6+RHh9m7EwnG7k4mGlV5oM/Fmg9GVnPksi788Y4/yHFdv wsfmwtALvcfmA== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 19 May 2023 19:42:32 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Bjorn Helgaas , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-pci@vger.kernel.org Subject: [PATCH] x86/PCI: Use struct_size() Date: Fri, 19 May 2023 19:42:28 +0200 Message-Id: <00a5cc2cd322e7dea26579916ac6dda9c637aa57.1684518118.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 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" Use struct_size() instead of hand-writing it. It is less verbose, more robust and more informative. Signed-off-by: Christophe JAILLET --- arch/x86/pci/irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c index a498b847d740..0de436316a1d 100644 --- a/arch/x86/pci/irq.c +++ b/arch/x86/pci/irq.c @@ -136,14 +136,14 @@ static inline struct irq_routing_table *pirq_convert_= irt_table(u8 *addr, if (ir->signature !=3D IRT_SIGNATURE || !ir->used || ir->size < ir->used) return NULL; =20 - size =3D sizeof(*ir) + ir->used * sizeof(ir->slots[0]); + size =3D struct_size(ir, slots, ir->used); if (size > limit - addr) return NULL; =20 DBG(KERN_DEBUG "PCI: $IRT Interrupt Routing Table found at 0x%lx\n", __pa(ir)); =20 - size =3D sizeof(*rt) + ir->used * sizeof(rt->slots[0]); + size =3D struct_size(rt, slots, ir->used); rt =3D kzalloc(size, GFP_KERNEL); if (!rt) return NULL; --=20 2.34.1