From nobody Wed Dec 17 19:21:06 2025 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6050B77F08 for ; Mon, 6 May 2024 13:03:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715000598; cv=none; b=CiBFh7kH18T2ZmRsn4A8SYTBIyqy/28A86rSCDIJRzdhxBG3XWu5a1IWTaUzJeTm/4XFNoCdZMfwixo18Zxrptlts4RM+GR3Cijsg76w925VjpOC9ymAmYE6jQYybVFzk79lvI9OSYq1ExRBtnz1xwAOeVeyV5F3SX1Sx/JGKMM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715000598; c=relaxed/simple; bh=uuxg5U4k/MG1J3jogr6OvT/NI4ZO8YphByPzlme47Wg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ajylu0GMLaJdD8J+tQ+gD7Gkqzhl4Pzgvmx8dIvYv9HIX5PW4tV2Ojbn5hdH7vfB1ioLUWDl3bD/fjYl5jd5AjJcvdQiuECDiL+k+HS8rkmz0/LhLvSLchXI1f1WY31uaZN8glVsclNGjr+OIPW+SdgQVFkzTzMA3ET1fRprduw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4VY1jS0mCtzNw6L for ; Mon, 6 May 2024 21:00:28 +0800 (CST) Received: from kwepemi500008.china.huawei.com (unknown [7.221.188.139]) by mail.maildlp.com (Postfix) with ESMTPS id B882418007D for ; Mon, 6 May 2024 21:03:12 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemi500008.china.huawei.com (7.221.188.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 6 May 2024 21:03:12 +0800 From: Jinjie Ruan To: , CC: Subject: [PATCH 4/5] genirq/irqdomain: Simplify the checks for irq_domain_push/pop_irq() Date: Mon, 6 May 2024 21:02:22 +0800 Message-ID: <20240506130223.317265-5-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240506130223.317265-1-ruanjinjie@huawei.com> References: <20240506130223.317265-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500008.china.huawei.com (7.221.188.139) Content-Type: text/plain; charset="utf-8" Since whether desc is NULL or domain is NULL or irq_data is NULL, it returns -EINVAL, check them together in irq_domain_push/pop_irq(). And whether the irq domain is not hierarchy or it's parent domain is not consistent, it returns -EINVAL, check them together too. Signed-off-by: Jinjie Ruan --- kernel/irq/irqdomain.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 6d8a368c677b..2ef53697d877 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -1613,21 +1613,14 @@ int irq_domain_push_irq(struct irq_domain *domain, = int virq, void *arg) * to deadlock, so we just do a simple check before starting. */ desc =3D irq_to_desc(virq); - if (!desc) + if (!desc || !domain || !irq_data) return -EINVAL; + if (WARN_ON(desc->action)) return -EBUSY; =20 - if (domain =3D=3D NULL) - return -EINVAL; - - if (WARN_ON(!irq_domain_is_hierarchy(domain))) - return -EINVAL; - - if (!irq_data) - return -EINVAL; - - if (domain->parent !=3D irq_data->domain) + if (WARN_ON(!irq_domain_is_hierarchy(domain)) || + domain->parent !=3D irq_data->domain) return -EINVAL; =20 parent_irq_data =3D kzalloc_node(sizeof(*parent_irq_data), GFP_KERNEL, @@ -1694,17 +1687,11 @@ int irq_domain_pop_irq(struct irq_domain *domain, i= nt virq) * deadlock, so we just do a simple check before starting. */ desc =3D irq_to_desc(virq); - if (!desc) + if (!desc || !domain || !irq_data) return -EINVAL; if (WARN_ON(desc->action)) return -EBUSY; =20 - if (domain =3D=3D NULL) - return -EINVAL; - - if (!irq_data) - return -EINVAL; - tmp_irq_data =3D irq_domain_get_irq_data(domain, virq); =20 /* We can only "pop" if this domain is at the top of the list */ --=20 2.34.1