From patchwork Wed Mar 27 14:23:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zenghui Yu X-Patchwork-Id: 13606726 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (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 1BC1E14535D; Wed, 27 Mar 2024 14:23:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711549425; cv=none; b=LYuPFJ45VvJyIYiRjACcTj4XWDfLbZsG8FASYwUsFpYMMPar1Zd7pFNDvxjAP6y43glRo0fpZcu2P5tz1BADkDS8Y+1MnKIfhKW2v/RMMrYF+HdVdLXNsRI94kHFvIByb2T452nCPMj4OAohhYl4MRdXk2zEa5WPAL6tWyOC6eo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711549425; c=relaxed/simple; bh=S2tOvnXnLBWrNcDCTWsN+3QjTxjM5oG6sC2mw1nYkFc=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=g3/gyK7qSS8YD4k8dPlfqvSh1XFdSYRsV1njTrHomUYssBpz8rqnmBAlLzusHA+FuzN4YBF3iokCWsNkFcpFWmf58DF1I5yBbCCW1fjRDiCd7IxT9cbQGXiCy8LhgSolsQZP3udYdhlGLzOt6xYmMGJellDZAvPciIU7STLItcI= 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.191 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.17]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4V4TRK37pRz1GCtg; Wed, 27 Mar 2024 22:23:09 +0800 (CST) Received: from kwepemm600007.china.huawei.com (unknown [7.193.23.208]) by mail.maildlp.com (Postfix) with ESMTPS id 74CCB1A0188; Wed, 27 Mar 2024 22:23:40 +0800 (CST) 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_256_GCM_SHA384) id 15.1.2507.35; Wed, 27 Mar 2024 22:23:39 +0800 From: Zenghui Yu To: , CC: , , , Zenghui Yu , Huacai Chen , Jiaxun Yang Subject: [PATCH] irqchip/loongson-pch-msi: Fix off-by-one on allocation error path Date: Wed, 27 Mar 2024 22:23:34 +0800 Message-ID: <20240327142334.1098-1-yuzenghui@huawei.com> X-Mailer: git-send-email 2.23.0.windows.1 Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600007.china.huawei.com (7.193.23.208) When pch_msi_parent_domain_alloc() returns an error, there is an off-by-one in the number of IRQs to be freed. Fix it by passing the number of successfully allocated IRQs, instead of the relative index of the last allocated one. Fixes: 632dcc2c75ef ("irqchip: Add Loongson PCH MSI controller") Cc: Huacai Chen Cc: Jiaxun Yang Signed-off-by: Zenghui Yu Reviewed-by: Jiaxun Yang --- drivers/irqchip/irq-loongson-pch-msi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-loongson-pch-msi.c b/drivers/irqchip/irq-loongson-pch-msi.c index 6e1e1f011bb2..dd4d699170f4 100644 --- a/drivers/irqchip/irq-loongson-pch-msi.c +++ b/drivers/irqchip/irq-loongson-pch-msi.c @@ -136,7 +136,7 @@ static int pch_msi_middle_domain_alloc(struct irq_domain *domain, err_hwirq: pch_msi_free_hwirq(priv, hwirq, nr_irqs); - irq_domain_free_irqs_parent(domain, virq, i - 1); + irq_domain_free_irqs_parent(domain, virq, i); return err; }