Received: by 10.223.185.116 with SMTP id b49csp5957970wrg; Wed, 28 Feb 2018 01:20:42 -0800 (PST) X-Google-Smtp-Source: AH8x227CWeS1cTluiVc2ApQSlpgl2EEO6D2lELxVwqIyzVeKGoILRRSteIYfH6oO/vB7IVsp0F+e X-Received: by 10.101.92.6 with SMTP id u6mr13698368pgr.440.1519809642819; Wed, 28 Feb 2018 01:20:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519809642; cv=none; d=google.com; s=arc-20160816; b=by23qmk2/9Ca+C4dekNw7e9Y24KlrlwuZLD6ww/dAKzmdylPoZynWkwrXZMlJDdG5X tbo/vxwlnLyKzTTFyBgRh6G3UAIMDoeev9WsABZuF4zTR1sH6zIVbXXMNqlXizeBVpan MmZ7kd5dFdAiqt98bgC2T7R4JsBuG5C51BMWuVyArmeSmMptObGoR/lE80R1g57xwvOJ 8ZGupANDrbrhjy5mk41JkXx1/6EYJ6zYrfVAxtrbc8SwV+6CzuVVN7CqWNRdNijDVfrA 0b1LDOTj5klH+81fd/ziEwoIedtJmt1nBCIIulPGZpbWSXRrt1G9VGp52rYeCevzqpL9 mYNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:arc-authentication-results; bh=L60KcYH03nTWGJ6nXz8Knb22/2JVyB4L+hf68fTAS+U=; b=afw9cv5kBVVc9edbj10r05SG+wQ1VnhCniIHr3hgG72R4OYeDqNtfBn2u5ibV/8yIc Z9if2J+NLQR4EHnPxEGQLGeJAItZP4YUfu4aRJZ7Pb6+A3Ja51JSHq1oVyqZjAZRsE9h D+MdkjmS3/Q3S0395tjKLZg4yHyT4UIN6fLqXMq9Yzat57Z4XpEkIV0SyB0tLud1wDjx eMKf6OUGkqg+0SN4NHBc9/YB51P80vZWqALNsHVUgGsw6x4qiIlw+n57S5aWiJdCp8FK qtyOqH3tIv4wBvpG9PLs3xAslIPASfsqtSIzvP+T+5OSmIWksZY2YKWqJfUg0Ck5KztC YaHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p17si781923pgq.8.2018.02.28.01.20.26; Wed, 28 Feb 2018 01:20:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752138AbeB1JTQ (ORCPT + 99 others); Wed, 28 Feb 2018 04:19:16 -0500 Received: from smtp.eu.citrix.com ([185.25.65.24]:49306 "EHLO SMTP.EU.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751574AbeB1JTO (ORCPT ); Wed, 28 Feb 2018 04:19:14 -0500 X-IronPort-AV: E=Sophos;i="5.47,405,1515456000"; d="scan'208";a="68761293" From: Roger Pau Monne To: CC: Roger Pau Monne , Boris Ostrovsky , Juergen Gross , Amit Shah , , Subject: [PATCH] xen/pirq: fix error path cleanup when binding MSIs Date: Wed, 28 Feb 2018 09:19:03 +0000 Message-ID: <20180228091903.99889-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.16.1 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: AMSPEX02CAS02.citrite.net (10.69.22.113) To AMSPEX02CL02.citrite.net (10.69.22.126) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Current cleanup in the error path of xen_bind_pirq_msi_to_irq is wrong. First of all there's an off-by-one in the cleanup loop, which can lead to unbinding wrong IRQs. Secondly IRQs not bound won't be freed, thus leaking IRQ numbers. Note that there's no need to differentiate between bound and unbound IRQs when freeing them, __unbind_from_irq will deal with both of them correctly. Fixes: 4892c9b4ada9f9 ("xen: add support for MSI message groups") Reported-by: Hooman Mirhadi Signed-off-by: Roger Pau Monné --- Cc: Boris Ostrovsky Cc: Juergen Gross Cc: Amit Shah CC: stable@vger.kernel.org Cc: xen-devel@lists.xenproject.org --- drivers/xen/events/events_base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c index b241bfa529ce..159faf1269fb 100644 --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -763,8 +763,8 @@ int xen_bind_pirq_msi_to_irq(struct pci_dev *dev, struct msi_desc *msidesc, mutex_unlock(&irq_mapping_update_lock); return irq; error_irq: - for (; i >= 0; i--) - __unbind_from_irq(irq + i); + while (nvec--) + __unbind_from_irq(irq + nvec); mutex_unlock(&irq_mapping_update_lock); return ret; } -- 2.16.1