From nobody Sat Apr 18 04:21:49 2026 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 CE612C433EF for ; Mon, 18 Jul 2022 13:10:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235498AbiGRNKr (ORCPT ); Mon, 18 Jul 2022 09:10:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235477AbiGRNKa (ORCPT ); Mon, 18 Jul 2022 09:10:30 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 346C61D30A for ; Mon, 18 Jul 2022 06:10:29 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Lmj3T6SjHzFq9L; Mon, 18 Jul 2022 21:09:25 +0800 (CST) Received: from huawei.com (10.175.112.208) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 18 Jul 2022 21:10:26 +0800 From: Xu Qiang To: , CC: , , Subject: [PATCH -next 1/2] irqdomain: fix possible uninitialized variable in irq_find_mapping() Date: Mon, 18 Jul 2022 13:07:58 +0000 Message-ID: <20220718130759.67777-2-xuqiang36@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220718130759.67777-1-xuqiang36@huawei.com> References: <20220718130759.67777-1-xuqiang36@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.112.208] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In irq_find_mapping,ret value may be uninitialized.However,even if the local variable irq is initialized, it only solves the uninitialized problem and ret value is still an incorrect virq, so my modification method is to set virq in __irq_resolve_mapping function. Fixes: d22558dd0a6c (=E2=80=9Cirqdomain: Introduce irq_resolve_mapping()=E2= =80=9D) Signed-off-by: Xu Qiang --- kernel/irq/irqdomain.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index d5ce96510549..481abb885d61 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -910,6 +910,8 @@ struct irq_desc *__irq_resolve_mapping(struct irq_domai= n *domain, data =3D irq_domain_get_irq_data(domain, hwirq); if (data && data->hwirq =3D=3D hwirq) desc =3D irq_data_to_desc(data); + if (irq && desc) + *irq =3D hwirq; } =20 return desc; --=20 2.17.1 From nobody Sat Apr 18 04:21:49 2026 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 277B4C43334 for ; Mon, 18 Jul 2022 13:10:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234837AbiGRNKl (ORCPT ); Mon, 18 Jul 2022 09:10:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235481AbiGRNKa (ORCPT ); Mon, 18 Jul 2022 09:10:30 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4709F1D31F for ; Mon, 18 Jul 2022 06:10:29 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Lmj2l1f92zlVr8; Mon, 18 Jul 2022 21:08:47 +0800 (CST) Received: from huawei.com (10.175.112.208) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 18 Jul 2022 21:10:26 +0800 From: Xu Qiang To: , CC: , , Subject: [PATCH -next 2/2] irqdomain: Replace revmap_direct_max_irq field with hwirq_max field Date: Mon, 18 Jul 2022 13:07:59 +0000 Message-ID: <20220718130759.67777-3-xuqiang36@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220718130759.67777-1-xuqiang36@huawei.com> References: <20220718130759.67777-1-xuqiang36@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.208] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In commit "4f86a06e2d6e irqdomain: Make normal and nomap irqdomains exclusi= ve", use revmap_size field instead of revmap_direct_max_irq. revmap_size field originally indicates the maximum hwirq of linear Mapping. This results in revmap_size having two different layers of meaning that can be confusing. This patch optimization point is to solve this confusion point. During direct mapping, the values of hwirq_max and revmap_direct_max_irq are the s= ame and have the same meanings. They both indicate the maximum hwirq supported = by direct Mapping. The optimization method is to delete revmap_direct_max_irq field and use hwirq_max instead of revmap_direct_max_irq. Signed-off-by: Xu Qiang Reported-by: kernel test robot --- kernel/irq/irqdomain.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 481abb885d61..384eb9166804 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -147,7 +147,8 @@ struct irq_domain *__irq_domain_add(struct fwnode_handl= e *fwnode, unsigned int s static atomic_t unknown_domains; =20 if (WARN_ON((size && direct_max) || - (!IS_ENABLED(CONFIG_IRQ_DOMAIN_NOMAP) && direct_max))) + (!IS_ENABLED(CONFIG_IRQ_DOMAIN_NOMAP) && direct_max) || + (direct_max && (direct_max !=3D hwirq_max)))) return NULL; =20 domain =3D kzalloc_node(struct_size(domain, revmap, size), @@ -219,7 +220,6 @@ struct irq_domain *__irq_domain_add(struct fwnode_handl= e *fwnode, unsigned int s domain->hwirq_max =3D hwirq_max; =20 if (direct_max) { - size =3D direct_max; domain->flags |=3D IRQ_DOMAIN_FLAG_NO_MAP; } =20 @@ -650,9 +650,9 @@ unsigned int irq_create_direct_mapping(struct irq_domai= n *domain) pr_debug("create_direct virq allocation failed\n"); return 0; } - if (virq >=3D domain->revmap_size) { + if (virq >=3D domain->hwirq_max) { pr_err("ERROR: no free irqs available below %i maximum\n", - domain->revmap_size); + domain->hwirq_max); irq_free_desc(virq); return 0; } @@ -906,7 +906,7 @@ struct irq_desc *__irq_resolve_mapping(struct irq_domai= n *domain, return desc; =20 if (irq_domain_is_nomap(domain)) { - if (hwirq < domain->revmap_size) { + if (hwirq < domain->hwirq_max) { data =3D irq_domain_get_irq_data(domain, hwirq); if (data && data->hwirq =3D=3D hwirq) desc =3D irq_data_to_desc(data); --=20 2.17.1