Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1372448lqh; Mon, 6 May 2024 06:04:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUnU82A5HFMhOUnk4vfVtHQht31XK1fT4JhUTAbpNoZCPPeBk7NKNe4cnIp4kf03eBkUy7cFBLWLOfbzpBbgPaLduKKFclH2oQwQeCsuw== X-Google-Smtp-Source: AGHT+IGO2DVvaVoYVv49nznwSPpEYoBrkSXmRaeSqMGm6tqs/U6CL7Ml7vFqOVvuIDAiFN4WGOnP X-Received: by 2002:a05:622a:5a85:b0:437:b582:cbc9 with SMTP id fz5-20020a05622a5a8500b00437b582cbc9mr23854016qtb.24.1715000654940; Mon, 06 May 2024 06:04:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715000654; cv=pass; d=google.com; s=arc-20160816; b=IlKQXS1bHqYYDUod+dHzBQS/qc9/mFlYSeKKd2JpVF0nxu2AKjEfli2V8ewWL+ZGfw kLQLiD1WB9xz+V6F2i0InX0ZdkMKN+zqqr5tx2PW4G2tA+wC/ftyEQ9JQpzf18EB7tR3 1CEhEMxb/1Hd17adqz85zao8ck8FMK4bEofBQdVYoaSJVMAFeS+z1FqDOBbwtnIl/zJ/ GLTT+MyiuDYO45g0Ed4IVBnwSdf5UwobYajXGj0eKJHfRw9LA3i+p1xAIN4W4Bb09Tjs 367oJG3mnoss9/A3b6UOoVnSuT6Ci6mj9e3HKePRZkZra2BlbUYtai0h/DWyrzgDnPVM AJhw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=pHSTwIV+kz33gaNW8W0gLH/8IW/yLw2xZpOpwNo36Wo=; fh=iQIEIpegfxGHAXzmCmQbfua7u3pb28YTuJpmY/Z0V14=; b=zuBJZEwbjbB1LZ1jushcXdhhZx7R5fnoZ+eHcEmElIlYekiocyi5CK91b1s4tcNSwa Zmp/uHnq8uqjenJb3V44NmqzjmAfVEZRZGtqWaNzOq6JVCcokm5DVdpOQxNhzUmZfsWa S2tM7taK/g3+D0HNHNtX3aTpxhxfiZEgluyCU5bGJgmNzO/WmSBS+UN1tkyVnw+SsbOM WrPiLivKvYQ29pSu/85dKYvWn3xkXgtBP/omvx/AwOJQz6CpN0XcBVqhcKjLtveLHG9W e5AMziMOpaEneh4uqMp4Kc3wlv32P1s8Ao3+6tPOCkKXJf1XMt+c9xwBzla5Lc5CcCiJ n3jQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-169864-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169864-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id fc9-20020a056130178900b007f68a77dd0dsi785412uab.185.2024.05.06.06.04.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 06:04:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169864-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-169864-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169864-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9FC481C22CEA for ; Mon, 6 May 2024 13:04:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0072F7A140; Mon, 6 May 2024 13:03:19 +0000 (UTC) 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: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500008.china.huawei.com (7.221.188.139) 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 = irq_to_desc(virq); - if (!desc) + if (!desc || !domain || !irq_data) return -EINVAL; + if (WARN_ON(desc->action)) return -EBUSY; - if (domain == NULL) - return -EINVAL; - - if (WARN_ON(!irq_domain_is_hierarchy(domain))) - return -EINVAL; - - if (!irq_data) - return -EINVAL; - - if (domain->parent != irq_data->domain) + if (WARN_ON(!irq_domain_is_hierarchy(domain)) || + domain->parent != irq_data->domain) return -EINVAL; parent_irq_data = kzalloc_node(sizeof(*parent_irq_data), GFP_KERNEL, @@ -1694,17 +1687,11 @@ int irq_domain_pop_irq(struct irq_domain *domain, int virq) * deadlock, so we just do a simple check before starting. */ desc = irq_to_desc(virq); - if (!desc) + if (!desc || !domain || !irq_data) return -EINVAL; if (WARN_ON(desc->action)) return -EBUSY; - if (domain == NULL) - return -EINVAL; - - if (!irq_data) - return -EINVAL; - tmp_irq_data = irq_domain_get_irq_data(domain, virq); /* We can only "pop" if this domain is at the top of the list */ -- 2.34.1