Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp271200rdb; Mon, 18 Sep 2023 14:49:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/513F3PgmXDPA01qDkawLJ+RM2pZvXS6Cgf8feoryhFsfGXnle6TV2iamX1S2S8xJHrys X-Received: by 2002:a17:903:1c5:b0:1bd:ca21:c83 with SMTP id e5-20020a17090301c500b001bdca210c83mr9212808plh.68.1695073764655; Mon, 18 Sep 2023 14:49:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695073764; cv=none; d=google.com; s=arc-20160816; b=TeMAMKEeFhgg59GEQKFJJbxW5O975v+d5iGbApOZSyndeKQQ7YFitVz7zremecA0W5 eLpOksL8S45/GMmfFZeS97ZhDG5LfZYXFG6GfHMLPcq6M4w7l7DF5ct94VqZOMqcEKMw /M1ojCv2JUkAfhn6eYaZg8LKJp2OLxyfiatzYsz06vfJJjdG0SltDBmkggMi3DHrUKy0 WuXHD1MbhtOy+WX3tAQKtuzL3VVQUmTB6HuuiUBQ1hf5YDjNwamuTLKEurXUeEwyLlTu uEb2Ob2iB1skQZdlgAm/4upwR5pSqMhjftiw9GFfaN+670PSlL7RyIM2H4tTsfy7EKwx lJQQ== 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=EbtElBeNsbE4GMIml3vOc6qFz4synkMKkX+l0Phr2SY=; fh=x0hge2vW9GltvbojcRZHmoxNFjuXRZ1UwvGsDK7VfP4=; b=cWdZf+NkMnqbthCetrEm0L9RHoOMyyMNSo5tK8nhwrkQ1h5NaTAVNGNbSubxnYau9J ajxC1A5VQCbNXVI482rjD3GQfp9C95XEk+qy2KjOinHCy4mDlsliY8nwTMwwFtiAvXh/ SikAvjt3UpD35DbLcie7k/kgFp251qV13x9WZms3chX/0bSk+bkr4U67bOaTHlQdGRTE XzWE6pzEn8Px11qImUkT+dBg8YQj8ZO1V/SsiXuZ5apYBZof59SqW2sktvNUefP5k9uE 3RR1lNWMmZ+EIdjDopHEyyqazj3iR1lFbg5CUROxkeYS3nUqBolejnDqcPY8YBzEQnR+ cf9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="IP/9MHh1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id c12-20020a170902d48c00b001c44c2a2fcasi5266679plg.222.2023.09.18.14.49.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 14:49:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="IP/9MHh1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E2CB5806581E; Mon, 18 Sep 2023 02:17:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237689AbjIRJQ2 (ORCPT + 99 others); Mon, 18 Sep 2023 05:16:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240956AbjIRJQM (ORCPT ); Mon, 18 Sep 2023 05:16:12 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C3EA115; Mon, 18 Sep 2023 02:16:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695028560; x=1726564560; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=HODBa9dvinX682mpZpv2Ai5XBCfJ9WWcaCt3+KCr9MA=; b=IP/9MHh1rjBlQRZIaHpSyD/hlfzkk7ULJGQwmPiYj4M3beR1z78F0KqW YqgAOTpSqqcFofsnwCC3/PLYaBjzJo486zaleoPcWZsSapDmJSWorelMQ C5NXnZmeGUNgbR42yuZqxTj5ufroE7Y4wP37/nrBjQRhsq1mviFCv6CUH 5aNCViR4RtvFEKymtldl4Y2DOpKFdcO1tUIWvQMonDnsrcQc9HrnklfyX /2QLioDZ58evPyxyNlfJhnzRGcLZLsinzd1hukJ7dF7kV44n7hGeJtqSz YJC+d5BlIN2ICYKQjbwyoJ7s8x8pg4qWZcZSpZj+iP3jdpw+M8VxX6C6n w==; X-IronPort-AV: E=McAfee;i="6600,9927,10836"; a="382350896" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="382350896" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 02:15:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10836"; a="695455798" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="695455798" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 18 Sep 2023 02:15:56 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 584F118E; Mon, 18 Sep 2023 12:15:55 +0300 (EEST) From: Andy Shevchenko To: Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Cc: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Nathan Chancellor , Nick Desaulniers , Tom Rix , Andy Shevchenko Subject: [PATCH v1 1/1] gpiolib: cdev: Annotate struct linereq with __counted_by() Date: Mon, 18 Sep 2023 12:15:53 +0300 Message-Id: <20230918091553.1103567-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Mon, 18 Sep 2023 02:17:14 -0700 (PDT) Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions). Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib-cdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c index a5bbbd44531f..e23f06f58234 100644 --- a/drivers/gpio/gpiolib-cdev.c +++ b/drivers/gpio/gpiolib-cdev.c @@ -572,7 +572,7 @@ struct linereq { DECLARE_KFIFO_PTR(events, struct gpio_v2_line_event); atomic_t seqno; struct mutex config_mutex; - struct line lines[]; + struct line lines[] __counted_by(num_lines); }; #define GPIO_V2_LINE_BIAS_FLAGS \ -- 2.40.0.1.gaa8946217a0b