From patchwork Thu Jan 6 07:14:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Jin X-Patchwork-Id: 457841 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p067FGlN019976 for ; Thu, 6 Jan 2011 07:15:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753929Ab1AFHPP (ORCPT ); Thu, 6 Jan 2011 02:15:15 -0500 Received: from rcsinet10.oracle.com ([148.87.113.121]:43161 "EHLO rcsinet10.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753612Ab1AFHPO (ORCPT ); Thu, 6 Jan 2011 02:15:14 -0500 Received: from rcsinet13.oracle.com (rcsinet13.oracle.com [148.87.113.125]) by rcsinet10.oracle.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id p067ExEo028499 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 6 Jan 2011 07:15:03 GMT Received: from acsmt353.oracle.com (acsmt353.oracle.com [141.146.40.153]) by rcsinet13.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id p067EwBA004186; Thu, 6 Jan 2011 07:14:58 GMT Received: from abhmt019.oracle.com by acsmt354.oracle.com with ESMTP id 934534981294298060; Wed, 05 Jan 2011 23:14:20 -0800 Received: from [10.182.120.253] (/10.182.120.253) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 05 Jan 2011 23:14:19 -0800 Message-ID: <4D256BC7.1080501@oracle.com> Date: Thu, 06 Jan 2011 15:14:15 +0800 From: Joe Jin User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre OracleBeehiveExtension/1.0.0.2-OracleInternal ObetStats/CATLAF_1292475699435-498544290 Thunderbird/3.1.7 MIME-Version: 1.0 To: Ian Campbell CC: Konrad Rzeszutek Wilk , "jeremy@goop.org" , Andrew Morton , "linux-fbdev@vger.kernel.org" , "xen-devel@lists.xensource.com" , "linux-kernel@vger.kernel.org" , "gurudas.pai@oracle.com" , "greg.marsden@oracle.com" , "guru.anbalagane@oracle.com" Subject: Re: [patch] xenfb: fix xenfb suspend/resume race References: <20101230125616.GA31537@joejin-pc.cn.oracle.com> <20101230164051.GC24313@dumpdata.com> <1294139733.3831.141.camel@zakaz.uk.xensource.com> In-Reply-To: <1294139733.3831.141.camel@zakaz.uk.xensource.com> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 06 Jan 2011 07:15:16 +0000 (UTC) diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c index dc72563..367fb1c 100644 --- a/drivers/video/xen-fbfront.c +++ b/drivers/video/xen-fbfront.c @@ -561,26 +561,24 @@ static void xenfb_init_shared_page(struct xenfb_info *info, static int xenfb_connect_backend(struct xenbus_device *dev, struct xenfb_info *info) { - int ret, evtchn; + int ret, evtchn, irq; struct xenbus_transaction xbt; ret = xenbus_alloc_evtchn(dev, &evtchn); if (ret) return ret; - ret = bind_evtchn_to_irqhandler(evtchn, xenfb_event_handler, + irq = bind_evtchn_to_irqhandler(evtchn, xenfb_event_handler, 0, dev->devicetype, info); - if (ret < 0) { + if (irq < 0) { xenbus_free_evtchn(dev, evtchn); xenbus_dev_fatal(dev, ret, "bind_evtchn_to_irqhandler"); - return ret; + return irq; } - info->irq = ret; - again: ret = xenbus_transaction_start(&xbt); if (ret) { xenbus_dev_fatal(dev, ret, "starting transaction"); - return ret; + goto unbind_irq; } ret = xenbus_printf(xbt, dev->nodename, "page-ref", "%lu", virt_to_mfn(info->page)); @@ -602,15 +600,20 @@ static int xenfb_connect_backend(struct xenbus_device *dev, if (ret == -EAGAIN) goto again; xenbus_dev_fatal(dev, ret, "completing transaction"); - return ret; + goto unbind_irq; } xenbus_switch_state(dev, XenbusStateInitialised); + info->irq = irq; return 0; error_xenbus: xenbus_transaction_end(xbt, 1); xenbus_dev_fatal(dev, ret, "writing xenstore"); + unbind_irq: + printk(KERN_ERR "xenfb_connect_backend failed!\n"); + unbind_from_irqhandler(irq, info); + xenbus_free_evtchn(dev, evtchn); return ret; } diff --git a/drivers/xen/events.c b/drivers/xen/events.c index ac7b42f..4028704 100644 --- a/drivers/xen/events.c +++ b/drivers/xen/events.c @@ -175,6 +175,10 @@ static struct irq_info *info_for_irq(unsigned irq) static unsigned int evtchn_from_irq(unsigned irq) { + if (unlikely(irq < 0 || irq >= nr_irqs)) { + WARN_ON(1, "[%s]: Invalid irq(%d)!\n", __func__, irq); + return 0; + } return info_for_irq(irq)->evtchn; }