Received: by 2002:ab2:6991:0:b0:1f2:fff1:ace7 with SMTP id v17csp110928lqo; Wed, 27 Mar 2024 08:13:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV7q6hjFxj5SagWdlO2oU7H9ky1a09qpegHxRDmQCwuwhGSO1hZLkh/0wjpJPznMg3Mea4vH3Fq7n3qEL69uprSsxDSgBpYDbZJfD3uUA== X-Google-Smtp-Source: AGHT+IHGPi1sJ7oY7+aozwDwJkATB5ATKhfFZsWFIz8QT2DWLym7IOHl0gU0ivjYpOHrbmyMhXeR X-Received: by 2002:a17:906:b094:b0:a47:4a32:604 with SMTP id x20-20020a170906b09400b00a474a320604mr2222510ejy.26.1711552415241; Wed, 27 Mar 2024 08:13:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711552415; cv=pass; d=google.com; s=arc-20160816; b=poxxUiqGzXnt3HiLm+wtbGMfoesXaHsC/PvwFVR0cMGhurSDLXGBbcEzCiky+kHe5P nBqmzFQU9AzOwaJmP5M3xCfvtnYkikm2RYbaeY3LwBka5UcDrRtNBejaR40cDpe4yy4Z lYj17zdhctHFmAa9nIh5iJarwzwxteQBFsr49vqk63lyByZE3/wlft9iUA8v6RKqHoLQ qkmGF2gCdhSKNJnVgWQ7zdfdjZHhzb4DRMvu7BD3Mng+5T+wAOshsFcCzsZXRFslN7w1 EGWKKqyGgx2Wz3EWoixAUJ498IahyWI6aOEBMqrA6hIkJemoZ9jlqr00gX3GtyyevfBo etnA== 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:message-id:date:subject:cc:to :from; bh=uR2yNyUKPNv9vKKiJbDJ+3Cs/EDcXdaImepU9ke7Iok=; fh=sMK96cgBRatukdZbbh4pfnt15Ay9Fl6fNhrVkCdhvR0=; b=MjegaSuvqdpsM/qoYpzBgUZ2qTv7sZIzAaNXyiYJTrHOWqc3AsFKLGdTKK0K2nBi6a jIV8le+bUi/v9RiKTOdoy84VkAox+kXtb4QFyfeySXNuCkWMsnYkYk4fuHUJCqnXMSZM k3YHt7Rygql5lsHY5MKLp0EiC6+a+TfOr6c7B1BRm6KeuF0p2ob9VUdiNPIdjhxPR7dD l+DDcmaDfBwBWbX5iqHCAdDH88gZwRWlw31tSO3w6/88KJuGsfwFwru/yUwprgTnjctY z5g3suz9X4D4p5FoSYvc1p3V1Q7UpOBRTIhZZlBcVtppSgEiVnfBrfl6+8nnqXDBg/fs VMaQ==; 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-121426-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121426-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id me13-20020a170906aecd00b00a46f569aab3si4556319ejb.686.2024.03.27.08.13.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:13:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121426-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-121426-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121426-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 706391F33BF0 for ; Wed, 27 Mar 2024 15:04:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CE9C1146D5F; Wed, 27 Mar 2024 14:23:45 +0000 (UTC) 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-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 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 --- 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; } -- 2.33.0