Received: by 10.223.185.116 with SMTP id b49csp5192253wrg; Tue, 27 Feb 2018 09:11:33 -0800 (PST) X-Google-Smtp-Source: AG47ELslAm3vYgZPI6iQHEUEuIdWvh/xcVT9w2DVeBLmE8RCGTE2sXOumADEiWESSGTZSv4qLngx X-Received: by 10.98.72.10 with SMTP id v10mr7774560pfa.148.1519751493776; Tue, 27 Feb 2018 09:11:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519751493; cv=none; d=google.com; s=arc-20160816; b=IMGLfnWKYhazFVBNozvBkyacLo+JhCNRecQ7GoUFnMYvED3bHx0cEmWkIMBeU0x8qo 6zJRS1iGHzxJRW6gHK8CgiR7ALcoSD4IFRmHS4S1szRZsMFOm3nm2I33zFUoykRd6c41 P33kWYBBdunb4w3LzmaPHCAZmz3rFA2eLyktYxvre5RyAlv86sViu5AAdKPc/+PHncpT uWqgdC89rPUa6+00G8MvzX6amY+IZOZ4/zqDM4GC9O9WCvu7nQvRpZJxxn1ovUli/3S/ e8NkKj4EzZi/jRZTlKND/dHGMOhQgaXalQwku1Bl0cdApi+rGQlOiHnfnlXwxvhk8s1D 54xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=K/JYK8Z3Ot+ueJZipXXylJksodOwoUEYSYbzEcjzBp8=; b=v8mK3RFLzZrZi8yih8dpnvFLEGeeYIOBJIRSX0qO2l/PNxIaU+pgV2OFwdjsHVd0VW b2VHsEHwFvmYY6Dt/Cv6GaMzEaU8tfEMJJO+KSC5Hxxt8QIWsboiUD6QuB5vHUJXXeU+ XkXprDt188dKwuJof+tkd1OY2otUsPeYMchtou/eJwt6uKBHIMDpFw/RDvsGut5sWRkP 4U72B6cwXvKvUJTqs9fnO4CG9eP2o5+6iM4SjzxSgB2D0DW2NhnWm38qdupdSlhSrBJK jtuK9IYc5k8cSDSDRPGQK9RlQHhfbUKonM/pbLDM2XrcsQK8owRd3NLboPe6LMCDiPBW 8eVQ== 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 j20si8830218pff.85.2018.02.27.09.11.18; Tue, 27 Feb 2018 09:11:33 -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 S1751993AbeB0RKM (ORCPT + 99 others); Tue, 27 Feb 2018 12:10:12 -0500 Received: from smtp.eu.citrix.com ([185.25.65.24]:4724 "EHLO SMTP.EU.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750938AbeB0RKL (ORCPT ); Tue, 27 Feb 2018 12:10:11 -0500 X-IronPort-AV: E=Sophos;i="5.47,401,1515456000"; d="scan'208";a="68707722" Date: Tue, 27 Feb 2018 17:07:40 +0000 From: Roger Pau =?iso-8859-1?Q?Monn=E9?= To: Amit Shah CC: , , , Boris Ostrovsky , Eduardo Valentin , Juergen Gross , Thomas Gleixner , "K. Y. Srinivasan" , Liu Shuo , Anoob Soman Subject: Re: [PATCH v2 2/2] xen: events: free irqs in error condition Message-ID: <20180227170740.jcaxsvpepsn6eot2@MacBook-Pro-de-Roger.local> References: <1519746958-52077-1-git-send-email-aams@amazon.com> <1519746958-52077-3-git-send-email-aams@amazon.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1519746958-52077-3-git-send-email-aams@amazon.com> User-Agent: NeoMutt/20171215 X-ClientProxiedBy: AMSPEX02CAS01.citrite.net (10.69.22.112) 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 On Tue, Feb 27, 2018 at 03:55:58PM +0000, Amit Shah wrote: > In case of errors in irq setup for MSI, free up the allocated irqs. > > Fixes: 4892c9b4ada9f9 ("xen: add support for MSI message groups") > Reported-by: Hooman Mirhadi > CC: > CC: Roger Pau Monn? > CC: Boris Ostrovsky > CC: Eduardo Valentin > CC: Juergen Gross > CC: Thomas Gleixner > CC: "K. Y. Srinivasan" > CC: Liu Shuo > CC: Anoob Soman > Signed-off-by: Amit Shah > --- > drivers/xen/events/events_base.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c > index c86d10e..a299586 100644 > --- a/drivers/xen/events/events_base.c > +++ b/drivers/xen/events/events_base.c > @@ -750,11 +750,14 @@ int xen_bind_pirq_msi_to_irq(struct pci_dev *dev, struct msi_desc *msidesc, > > ret = irq_set_msi_desc(irq, msidesc); > if (ret < 0) > - goto error_irq; > + goto error_desc; > out: > mutex_unlock(&irq_mapping_update_lock); > return irq; > error_irq: > + while (--nvec >= i) > + xen_free_irq(irq + nvec); > +error_desc: > while (i > 0) { > i--; > __unbind_from_irq(irq + i); It seems pointless to introduce another label and another loop to fix something that can be fixed with a single label and a single loop, this just makes the code more complex for no reason. IMHO the way to solve this issue is: while (nvec--) { if (nvec >= i) xen_free_irq(irq + nvec); else __unbind_from_irq(irq + nvec); } Roger.