Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp2872359rdh; Mon, 27 Nov 2023 00:30:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGyrOQYfZ37/Pb79XdvxkrPhXNwNV1ojcmtzR6l7Uinxv25EJ8B8w+8z2XdsaDzoov24F0S X-Received: by 2002:a05:6a20:8096:b0:18b:d248:bafb with SMTP id c22-20020a056a20809600b0018bd248bafbmr8238587pza.25.1701073806314; Mon, 27 Nov 2023 00:30:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701073806; cv=none; d=google.com; s=arc-20160816; b=dnYsx38BF69wrBU2lLHEPXmdNJdJB1tvPuvzyQZyNVbCBUgvr2/FYfOGRy8c86xj+9 wa/fYSf5iqvgLB6G602Ass/sPGdZX6E0dpK0A4TIlYvy7x7MMmdtmGPnSYPIOVSZEAjG r9ro2clELopSdDLOx1KgDUo307OaBdsYdUZPsbAomZxwTnbTcUM1ja0YxeIi883ISwWX KSLT+K5DqyO0hNJLMcEy4HbSfsPjtagC7xyjSOo719RFozhAaX/3m/QGPV/3dXyNPV02 +uDF9EEEhAORg5E76JyGtCUJGGAyNSu4ZPReJcAtyccSN5idmgnWDaHGiYx0SCfqrT1N g65g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2CdZagPBNXqbD/b1Zs1TWZBKxImZV6/P7uarWOkiV20=; fh=t8auLOVHmHNH/Il20WGKFNjt63GUc46ZML6hsqoIYOI=; b=E+BeomhXxT3bO3mVmslUI1azKglO+/q8UxwCq+92vBkeBQtxvwSbeyn0oQ/7xrGSTG BSJv4G8OHwV6Y42Zkv2gI7jcynA1Jt+N5wq8uehXtUjmlFe/CEbZEBHraE30nSqcctCA MFZAESlkJ6NKqnBix0+uuubH1Wb8J9T2fzhdOnFEvcFgiuGqi9padVXR4y5gaRLDFJ57 ywU+RBC+5/YsRAGGV8W5v0fdn29Mj/3BYAPT1jtihB0OsRopC4jV7TMgcBKsvW3/v7ob ZnO4YlTHHt8yPBm3FQtDXLNg5hy/jYFkWgBbLGiOJgx3W5VlDxMlUtFOiiXCdT+96Lcg N8Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xMae0OGa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id by16-20020a056a02059000b00563f627f2easi10457759pgb.122.2023.11.27.00.30.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 00:30:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xMae0OGa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 38FFA8095035; Mon, 27 Nov 2023 00:30:05 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232633AbjK0I3y (ORCPT + 99 others); Mon, 27 Nov 2023 03:29:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232452AbjK0I3x (ORCPT ); Mon, 27 Nov 2023 03:29:53 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E9E5D6 for ; Mon, 27 Nov 2023 00:30:00 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-332e42469f0so2441255f8f.1 for ; Mon, 27 Nov 2023 00:29:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701073798; x=1701678598; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=2CdZagPBNXqbD/b1Zs1TWZBKxImZV6/P7uarWOkiV20=; b=xMae0OGarg23UsAdbLH5y+CDMD0rquxSioFprZC/RurORG+2uUwKnYXh0zNrNi5Tyg DKlZo2BYuVphBisaRSf+8nWH3YD+W2Tz4GHIEW3+n6mneCwZeGScD9qY/0F6BDEPbRH6 j3eRuVmvo4j/WCvVVdr+Yaay//4jJY02DM6maN+QM2DxZysjZuGF68J3Zh6kX7WVDYc6 2ZPOY19UVir3PGQ4edq1isdYeRBfmPdIZjJCNbzJ74ubm2GWHgcPJ/ulACux+xFry37r +PwCfztGKM4vWLmx9l8+5/9tRqBONaT+RjC08HOKx19MBnjMZSmBa1NmrdaMBPhnL1kz kuiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701073798; x=1701678598; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2CdZagPBNXqbD/b1Zs1TWZBKxImZV6/P7uarWOkiV20=; b=GT5/k/k8lcIo/GO5JhQj9Mgy/GrnmA7CUBg3ekdWm4868JxbaqbJ05Bz+Pxuhtp/jl fHtox6GXZwTnOjIBX0dxLVPPawl9kW3gHMKEoZeq5zdLBxIat4ZzrXn5UpXgxFHiCr2H 1WXJ803mX9bWBs6ghGuXMc7nh2a24EUN1oAktQhESH8YZMFg0q79MV405zzCCk/do/gs eAMGfyAg1vv/OzmwwNn8gcPv9C2pjCvvWJ+sXIUUxCduW69iQIiNqJ/Dc/4sYZE5W7pJ LlskAKh1cpTqhZArFrX2GCZiAGgZjLAD12TOpzHzG1P5ThQzqRppSl9q7v6vV0xJuVhS V+kw== X-Gm-Message-State: AOJu0Yw/lPVuxF5i452cfrEOiHSIkCHFiQARIy6GLAMkfOVG8iD+6/St 5T3i1H1K2N5X1ocQ8zQOOrZ2NQ== X-Received: by 2002:adf:f48d:0:b0:332:e4cc:6a38 with SMTP id l13-20020adff48d000000b00332e4cc6a38mr6966002wro.57.1701073798517; Mon, 27 Nov 2023 00:29:58 -0800 (PST) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id o10-20020adfcf0a000000b00332cda91c85sm11225013wrj.12.2023.11.27.00.29.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 00:29:58 -0800 (PST) Date: Mon, 27 Nov 2023 11:29:55 +0300 From: Dan Carpenter To: Christophe JAILLET Cc: Peter Rosin , Kees Cook , "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH 1/2] mux: Turn 'mux' into a flexible array in 'struct mux_chip' Message-ID: <19d7ddce-f911-481e-ac89-bc942e40fbe1@suswa.mountain> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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_BLOCKED, SPF_HELO_NONE,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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 27 Nov 2023 00:30:05 -0800 (PST) On Sun, Nov 26, 2023 at 09:08:11AM +0100, Christophe JAILLET wrote: > The 'mux' array stored in 'struct mux_chip' can be changed into a flexible > array. > > This saves: > - a pointer in the structure > - an indirection when accessing the array > - some pointer arithmetic when computing and storing the address in > 'mux' > > It is also now possible to use __counted_by() and struct_size() for > additional safety. > > The address for the 'priv' memory is computed with mux_chip_priv(). It > should work as good with a flexible array. > > Signed-off-by: Christophe JAILLET > --- > The struct_size() goodies only work if sizeof_priv is 0. Adding an > additional size_add() would make it safe in all cases but would make code > less readable (IMHO). Once people start using size_add() then we'll get used to reading it. The controllers value comes from device tree. For example, in mux_mmio_probe(). ret = of_property_count_u32_elems(np, "mux-reg-masks"); I should make Smatch parse device trees. So that it will know the correct range for ret in that assignment. Eventually, I will. KTODO: make Smatch understand device tree values regards, dan carpenter