From patchwork Fri Aug 12 11:33:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zenghui Yu X-Patchwork-Id: 596842 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72252C00140 for ; Fri, 12 Aug 2022 11:33:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237115AbiHLLdV (ORCPT ); Fri, 12 Aug 2022 07:33:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236894AbiHLLdU (ORCPT ); Fri, 12 Aug 2022 07:33:20 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF1ECAE9F3; Fri, 12 Aug 2022 04:33:19 -0700 (PDT) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4M41gd1vHYzlW1W; Fri, 12 Aug 2022 19:30:21 +0800 (CST) Received: from kwepemm600007.china.huawei.com (7.193.23.208) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 12 Aug 2022 19:33:17 +0800 Received: from DESKTOP-8RFUVS3.china.huawei.com (10.174.185.179) by kwepemm600007.china.huawei.com (7.193.23.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 12 Aug 2022 19:33:16 +0800 From: Zenghui Yu To: , CC: , , , Zenghui Yu , Sakari Ailus Subject: [PATCH] ACPI: property: Fix mis-use of _Generic() Date: Fri, 12 Aug 2022 19:33:08 +0800 Message-ID: <20220812113308.1772-1-yuzenghui@huawei.com> X-Mailer: git-send-email 2.23.0.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.174.185.179] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600007.china.huawei.com (7.193.23.208) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org It looks wrong to pass __val as the control-expression of _Generic() which will always return 0U this way and acpi_copy_property_array_uint() is likely to return -EOVERFLOW error whilst it actually doesn't. Use __val[i] to match the given type list. Fixes: 923044133367 ("ACPI: property: Unify integer value reading functions") Cc: Sakari Ailus Signed-off-by: Zenghui Yu --- drivers/acpi/property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 7b3ad8ed2f4e..1ededa618a88 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -1042,7 +1042,7 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data, ret = -EPROTO; \ break; \ } \ - if (__items[i].integer.value > _Generic(__val, \ + if (__items[i].integer.value > _Generic(__val[i], \ u8: U8_MAX, \ u16: U16_MAX, \ u32: U32_MAX, \