On 2/10/22 1:11 AM, Ard Biesheuvel wrote:
On Thu, 10 Feb 2022 at 01:34, Victor Erminpour
<victor.erminpour@xxxxxxxxxx> wrote:
When building with automatic stack variable initialization, GCC 12
complains about variables defined outside of switch case statements.
Move the variable into the case that uses it, which silences the warning:
./drivers/acpi/arm64/iort.c:1670:59: error: statement will never be executed [-Werror=switch-unreachable]
1670 | struct acpi_iort_named_component *ncomp;
| ^~~~~
Signed-off-by: Victor Erminpour <victor.erminpour@xxxxxxxxxx>
GCC 12 is not released yet, and this is clearly a compiler bug (a
declaration is not a statement, and the hidden offending statement
[the zero-init] is emitted by the compiler itself), so please report
this to the GCC folks instead.
Hi Ard,
Thanks for the reply.
This fix is similar to the following commits that have been integrated
upstream:
https://lore.kernel.org/linux-hardening/20211209043456.1377875-1-keescook@xxxxxxxxxxxx/
https://lore.kernel.org/linux-hardening/20211209043915.1378393-1-keescook@xxxxxxxxxxxx/
You're not obligated to integrate this commit, but you may run into this
issue once
upstream starts using GCC 12 (or a patched version of GCC 11 in my case)
with the
CONFIG_INIT_STACK_ALL_ZERO option enabled.
Regards,
--Victor
---
drivers/acpi/arm64/iort.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
index 3b23fb775ac4..5c5d2e56d756 100644
--- a/drivers/acpi/arm64/iort.c
+++ b/drivers/acpi/arm64/iort.c
@@ -1645,7 +1645,7 @@ void __init acpi_iort_init(void)
*/
phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
{
- phys_addr_t limit = PHYS_ADDR_MAX;
+ phys_addr_t local_limit, limit = PHYS_ADDR_MAX;
struct acpi_iort_node *node, *end;
struct acpi_table_iort *iort;
acpi_status status;
@@ -1667,17 +1667,15 @@ phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
break;
switch (node->type) {
- struct acpi_iort_named_component *ncomp;
- struct acpi_iort_root_complex *rc;
- phys_addr_t local_limit;
-
case ACPI_IORT_NODE_NAMED_COMPONENT:
+ struct acpi_iort_named_component *ncomp;
ncomp = (struct acpi_iort_named_component *)node->node_data;
local_limit = DMA_BIT_MASK(ncomp->memory_address_limit);
limit = min_not_zero(limit, local_limit);
break;
case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
+ struct acpi_iort_root_complex *rc;
if (node->revision < 1)
break;
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
https://urldefense.com/v3/__http://lists.infradead.org/mailman/listinfo/linux-arm-kernel__;!!ACWV5N9M2RV99hQ!dguMEUG-y4wN_Scw_dP1umWKxZKxiQA2Fv9sHuQx6Un9QIqSMbkQVxTeIZInR2h7YL-f$