From patchwork Tue Feb 2 17:40:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 18250 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id 22B5B83BED; Tue, 2 Feb 2021 18:50:22 +0100 (CET) Received: from simonwunderlich.de (simonwunderlich.de [79.140.42.25]) by diktynna.open-mesh.org (Postfix) with ESMTPS id DED4F80C86 for ; Tue, 2 Feb 2021 18:50:07 +0100 (CET) Received: from kero.packetmixer.de (p4fd575e2.dip0.t-ipconnect.de [79.213.117.226]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simonwunderlich.de (Postfix) with ESMTPSA id 05440174021; Tue, 2 Feb 2021 18:40:39 +0100 (CET) From: Simon Wunderlich To: kuba@kernel.org, davem@davemloft.net Subject: [PATCH 3/4] batman-adv: Avoid sizeof on flexible structure Date: Tue, 2 Feb 2021 18:40:35 +0100 Message-Id: <20210202174037.7081-4-sw@simonwunderlich.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210202174037.7081-1-sw@simonwunderlich.de> References: <20210202174037.7081-1-sw@simonwunderlich.de> MIME-Version: 1.0 ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1612288207; a=rsa-sha256; cv=none; b=FSg4kEXNgDQJpoIUEQwT3aORcvydSjXDCij9mm8olQBqcsKqrDGNGF/BJ5EPHGbmuckCI9 6ykZs4aY3mUHVcI1nuLTHb4oqeAAHikN8S2Qk7XXRy8qTti03vm2IgzaqhQVfw0PNJWKtk HfB+SHvN/ZaApEndERq2Fb+ypZLNEYc= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none; spf=pass (diktynna.open-mesh.org: domain of sw@simonwunderlich.de designates 79.140.42.25 as permitted sender) smtp.mailfrom=sw@simonwunderlich.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1612288207; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l0Qm2UIdq8n8eBfvaqdSrxxSvKkuq8/euIbeWcooZiE=; b=p8d1Z3BLwzf2gRm4OhpdGhoSC0S236qurE4hHL5ABMlyWDr7hnJt4mo6qiwSWHwVRxS1jm Clm52xvPSqBaXh/7mH4C5mp12Zk9lptRGrF7L0tRUQx0RzOzCk7EjwHZ21iyN0ZuV5nmeg daLbr5p6UPdlT35XQRc9PSWB3MLnavM= Message-ID-Hash: MSVKL6LPA3FIHC6SKEOIFEAXBPR53DVF X-Message-ID-Hash: MSVKL6LPA3FIHC6SKEOIFEAXBPR53DVF X-MailFrom: sw@simonwunderlich.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Sven Eckelmann The batadv_dhcp_packet is used to read in parts of the DHCP packet and extract relevant information for the distributed arp table. But the structure contained the flexible member "options" which is no where used in the code. A sizeof on this kind of type would return the size of everything except the flexible member. But sparse will detect this kind of sizeof and warn with warning: using sizeof on a flexible structure This can be avoided by dropping the unused flexible member. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/distributed-arp-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c index 443682a95af2..61a6cfef2742 100644 --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c @@ -87,7 +87,7 @@ struct batadv_dhcp_packet { __u8 sname[64]; __u8 file[128]; __be32 magic; - __u8 options[]; + /* __u8 options[]; */ }; #define BATADV_DHCP_YIADDR_LEN sizeof(((struct batadv_dhcp_packet *)0)->yiaddr)