]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
xen: close evtchn port if binding to irq fails
authorWei Liu <wei.liu2@citrix.com>
Mon, 18 Feb 2013 14:57:58 +0000 (14:57 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Feb 2013 13:38:30 +0000 (05:38 -0800)
commit e7e44e444876478d50630f57b0c31d29f6725020 upstream.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/xen/evtchn.c

index b1f60a0c0bea3e00627293101fd3dd38bb1fd96e..b2db77e5a5935f150b1b1067cebed9cac659ee08 100644 (file)
@@ -269,6 +269,14 @@ static int evtchn_bind_to_user(struct per_user_data *u, int port)
                                       u->name, (void *)(unsigned long)port);
        if (rc >= 0)
                rc = evtchn_make_refcounted(port);
+       else {
+               /* bind failed, should close the port now */
+               struct evtchn_close close;
+               close.port = port;
+               if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close) != 0)
+                       BUG();
+               set_port_user(port, NULL);
+       }
 
        return rc;
 }
@@ -277,6 +285,8 @@ static void evtchn_unbind_from_user(struct per_user_data *u, int port)
 {
        int irq = irq_from_evtchn(port);
 
+       BUG_ON(irq < 0);
+
        unbind_from_irqhandler(irq, (void *)(unsigned long)port);
 
        set_port_user(port, NULL);