From patchwork Fri May 5 21:20:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 90587 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp704392vqo; Fri, 5 May 2023 14:42:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5RNPGWsE4EBfNm5oZHWGmf1OjNIsLc8EZslD1LFt846jKby/SU1eBbbB8IIEYoyVHyA+En X-Received: by 2002:a17:902:da89:b0:1a2:37fc:b591 with SMTP id j9-20020a170902da8900b001a237fcb591mr3272468plx.69.1683322935160; Fri, 05 May 2023 14:42:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683322935; cv=none; d=google.com; s=arc-20160816; b=NWofxNlgG2O/Cr0tD6KnXIsCJenxRW2ZMXgQexh3xVym3isXz5FlDM6I+daqKPbHJ/ sLjI6lktgPUf+JwrN9piUVfb8atmFa5+rMrE2Ve0eMt3ZJLGV8wjgPQZ3i2EyDsYbVC8 timTINacmbZgf3OQWs0yAjnvy3rJCDZ4dD8YoEVAL0ZsLCp/XRzXvSAiuQnL85Q/7ceb EDWmL3IU7gEOza+VVVyv8WIVIlepSv+tnmXP6GZ4cxaZ9mnQgcYqSTQSvR45o30cfGxS Ffw8v6BdsJAS8n3C/JKyysUAcdJsKeDCnfqM9i4FI1poR1wY5FmoWAwNWViyE5p14bDD BuXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Chl4Ea7MDMRy9oRAihtzEgVAW8tW0wY55Exuo89iUjU=; b=A5otpBbQCphN5OCD2PZKYLkyM7Q+MpcNXsHzKo05GlBTeX8fPtpvu3lHG0TKZKqGRx IEwRvH/huLotCV84TR9ON08n97vR5N9kWyZ6pe2Iz3LDTUeo8oREOz6ysvMGIat8ejaa WOJxYz2EFZfmaaLnU4B5zpr3LEn7kJQoahHN/oLMB+ur96rNMM/5JOHsOtksfG+E0wyL hhT6WhyewEv3IFZmnojyz07kHqXf9t65lzPQdz/wufjg6ItmqHDBnAyl/+mgQ02sd2R4 /H8813DLvTkbdL5ZvqGU1wS57ofW+3+w3ZZEcIEwg7xV+zR1rZu0v0EG7ylxiO7Ac7Nx 0ubQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b="VDmL2/yu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n1-20020a170902e54100b001a66ff9542fsi2786562plf.616.2023.05.05.14.41.59; Fri, 05 May 2023 14:42:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b="VDmL2/yu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232390AbjEEVU1 (ORCPT + 99 others); Fri, 5 May 2023 17:20:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232171AbjEEVUZ (ORCPT ); Fri, 5 May 2023 17:20:25 -0400 Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E8F4525D for ; Fri, 5 May 2023 14:20:23 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id v2qdp5aQuunMHv2qdp7iGj; Fri, 05 May 2023 23:20:21 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1683321621; bh=Chl4Ea7MDMRy9oRAihtzEgVAW8tW0wY55Exuo89iUjU=; h=From:To:Cc:Subject:Date; b=VDmL2/yuUszQrahjQktLhU7UmxDcIthT3Kc3BmfKrkF8v1782xc9gi1rsKzBV6Jr1 alZVo4TUS4OSxk54mCx7g5LYdf3/Nip8dvgxVYeN6LblIQaIRlazqJTWCpio4Gl5aV uKqf2ARkccMFeSBGoAsCBvQxLVlZPo0NgDT2GfRfo/JlX7ztVvUKDBIqNRfkUPGIAo ynpOk3+EU75vOS4ct1Wr5VdIahz9RHzlIVXnclq3j0hFoVlUYHgRq2f31dvcoIIxF2 I2qmwfpqK1fPCxlZpwvCT1oeAuQG3A+GBnuJy1IGLl8u2yzxlynYpJtXVEfPMjRxIK zTeb+4SWWUqOQ== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 05 May 2023 23:20:21 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org Subject: [PATCH net-next] netfilter: nft_set_pipapo: Use struct_size() Date: Fri, 5 May 2023 23:20:14 +0200 Message-Id: <28e34aff5c8ee86411b5ebab6ff223c99935047a.1683321566.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765092029975074564?= X-GMAIL-MSGID: =?utf-8?q?1765092029975074564?= Use struct_size() instead of hand writing it. This is less verbose and more informative. Signed-off-by: Christophe JAILLET --- It will also help scripts when __counted_by macro will be added. See [1]. [1]: https://lore.kernel.org/all/6453f739.170a0220.62695.7785@mx.google.com/ --- net/netfilter/nft_set_pipapo.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/netfilter/nft_set_pipapo.c b/net/netfilter/nft_set_pipapo.c index 06d46d182634..bf290cb53c76 100644 --- a/net/netfilter/nft_set_pipapo.c +++ b/net/netfilter/nft_set_pipapo.c @@ -1274,8 +1274,7 @@ static struct nft_pipapo_match *pipapo_clone(struct nft_pipapo_match *old) struct nft_pipapo_match *new; int i; - new = kmalloc(sizeof(*new) + sizeof(*dst) * old->field_count, - GFP_KERNEL); + new = kmalloc(struct_size(new, f, old->field_count), GFP_KERNEL); if (!new) return ERR_PTR(-ENOMEM);