Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1724599pxb; Wed, 10 Feb 2021 15:29:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJyYqYqxRR00kft1R/Gh2LrlFcIWxPXi5bEIagLnAGyJlKhOJyM/UieklZ26Juy7DQ4/wvWa X-Received: by 2002:a05:6402:ce:: with SMTP id i14mr5546165edu.42.1612999791454; Wed, 10 Feb 2021 15:29:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612999791; cv=none; d=google.com; s=arc-20160816; b=O3cAx4KywhEczXt2JsylPlUsARl8EPTQaLe/n/evOp60dbyLfnVti14Qa+9oRjHoHy 4cS1cV8gU8wUjDee+Kax1ZgzrPnn1gMLA+uhp+Z8AUlySzHs6MuelzCUwjcKQDOscJdw K9jTOZP6d45OLy/QwvYSUwc8VBYFi+aUruvZJYDJJI2y5PFWD15Af2jIx8pQAayLJGY+ mKxQG3EoyvMB3kv2ZITh2jipO9+PxUsi3WHYuolOMpzfqo7zjz7kWuu5XhvT+TMN0yjF XlCwJ26rfhyYJhpwfRjGoUnEZi+7I46yCxrXT0dCFTM2LMsG7CG+EpcrdgW8F3YRhlzt 43vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=Zj+y4I8iBAPy1LImdx2syXVgBNU65XhD/iwECGSehGc=; b=tTjVUcfuxiJ5O9hz7C+C6xjGI63v9Y4t1p6uQytOLDeH01mmSwGt32JiZ5y0M0u5Dm oeizIyFbpXlNnQK4LU51plsMsp+QTDTXSlOQSByr69Eha5wu/d/YddBrA4/OtLiBVSDj zL/UQS6zS8o80HFFrN+dYj+FxwsXzS0yHuUQK91Iw6b66ivX3AMzWIldcwMHHAYPRKR8 /zXaNulwejH5ZBLUsgcdsVmTR63TfsccvRatup+nu9LP6vSUleVWZcFfmr5IZUMJXJjg NMKG3948mJxtueotUq0uWB+nl4khJbd75qEa+cadnBbsrHFkhXM+FltV1vS6j04i8mdH e8Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VHlMdkT+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rh23si2255947ejb.516.2021.02.10.15.29.28; Wed, 10 Feb 2021 15:29:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VHlMdkT+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233711AbhBJX1d (ORCPT + 99 others); Wed, 10 Feb 2021 18:27:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:37634 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234140AbhBJX0o (ORCPT ); Wed, 10 Feb 2021 18:26:44 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B226264EBB; Wed, 10 Feb 2021 23:26:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612999563; bh=z8PK7lQxdEjakhT1mHS5xkJS/hPiBnY76N9BArEFwI4=; h=Date:From:To:Cc:Subject:From; b=VHlMdkT+qJ2LMjznNTTzv1KOzBwgPGAT53rOQwZEt75wjMHB+z6g9eUm7YrFyNFXl 3+C7C+HhmgUJt/9n+dyLxhXE2xHxs8nWrkcXwnPQmM+LChfhsQgOiMmR6k6xqEVw9k M3IAjSHXGqTqGw+Gc7mLOwZZmnzCJoA6s8j76wAa3xQsF+3oLi1xCzzF6ljjdJp8J9 7omyZpecO7i8WzMbd0oIQTGH5YNFbkc2n+XtzKN3SGgPYleAz0hTvKVAb3onmc2Pwu g/RWjBSasGV/n7GjhUWUpf3AoY0PXmkDBFjD8DTDDtcGWqQZNQW7CtbsYD/V4aWS75 GFh0igzGmUaSA== Date: Wed, 10 Feb 2021 17:26:00 -0600 From: "Gustavo A. R. Silva" To: Evan Quan , Alex Deucher , Christian =?iso-8859-1?Q?K=F6nig?= , David Airlie , Daniel Vetter Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] drm/amd/pm: Replace one-element array with flexible-array in struct _ATOM_Vega10_GFXCLK_Dependency_Table Message-ID: <20210210232600.GA66488@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is a regular need in the kernel to provide a way to declare having a dynamically sized set of trailing elements in a structure. Kernel code should always use “flexible array members”[1] for these cases. The older style of one-element or zero-length arrays should no longer be used[2]. Use flexible-array member in struct _ATOM_Vega10_GFXCLK_Dependency_Table, instead of one-element array. Also, this helps with the ongoing efforts to enable -Warray-bounds and fix the following warning: drivers/gpu/drm/amd/amdgpu/../pm/powerplay/hwmgr/vega10_hwmgr.c: In function ‘vega10_get_pp_table_entry_callback_func’: drivers/gpu/drm/amd/amdgpu/../pm/powerplay/hwmgr/vega10_hwmgr.c:3113:30: warning: array subscript 4 is above array bounds of ‘ATOM_Vega10_GFXCLK_Dependency_Record[1]’ {aka ‘struct _ATOM_Vega10_GFXCLK_Dependency_Record[1]’} [-Warray-bounds] 3113 | gfxclk_dep_table->entries[4].ulClk; | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~ [1] https://en.wikipedia.org/wiki/Flexible_array_member [2] https://www.kernel.org/doc/html/v5.9/process/deprecated.html#zero-length-and-one-element-arrays Link: https://github.com/KSPP/linux/issues/79 Link: https://github.com/KSPP/linux/issues/109 Build-tested-by: kernel test robot Link: https://lore.kernel.org/lkml/6023ff3d.WY3sSCkGRQPdPlVo%25lkp@intel.com/ Signed-off-by: Gustavo A. R. Silva --- drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_pptable.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_pptable.h b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_pptable.h index c934e9612c1b..9c479bd9a786 100644 --- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_pptable.h +++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_pptable.h @@ -161,9 +161,9 @@ typedef struct _ATOM_Vega10_MCLK_Dependency_Record { } ATOM_Vega10_MCLK_Dependency_Record; typedef struct _ATOM_Vega10_GFXCLK_Dependency_Table { - UCHAR ucRevId; - UCHAR ucNumEntries; /* Number of entries. */ - ATOM_Vega10_GFXCLK_Dependency_Record entries[1]; /* Dynamically allocate entries. */ + UCHAR ucRevId; + UCHAR ucNumEntries; /* Number of entries. */ + ATOM_Vega10_GFXCLK_Dependency_Record entries[]; /* Dynamically allocate entries. */ } ATOM_Vega10_GFXCLK_Dependency_Table; typedef struct _ATOM_Vega10_MCLK_Dependency_Table { -- 2.27.0