WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] linux-2.6.18/fb: fix potential memory leak

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] linux-2.6.18/fb: fix potential memory leak
From: "Jan Beulich" <JBeulich@xxxxxxxxxx>
Date: Tue, 08 Feb 2011 17:15:51 +0000
Delivery-date: Tue, 08 Feb 2011 09:15:48 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
From: Joe Jin <joe.jin@xxxxxxxxxx>

This patch fixes a potential memory leak when xenfb connect to
the backend fails.

Thanks for Ian's review and comments.

[v2: reworded the commit message a bit]

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Signed-off-by: Joe Jin <joe.jin@xxxxxxxxxx>
Tested-by: Gurudas Pai <gurudas.pai@xxxxxxxxxx>
Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

Made apply to linux-2.6.18-xen.hg.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

--- a/drivers/xen/fbfront/xenfb.c
+++ b/drivers/xen/fbfront/xenfb.c
@@ -735,23 +735,22 @@ static void xenfb_init_shared_page(struc
 static int xenfb_connect_backend(struct xenbus_device *dev,
                                 struct xenfb_info *info)
 {
-       int ret;
+       int ret, irq;
        struct xenbus_transaction xbt;
 
-       ret = bind_listening_port_to_irqhandler(
+       irq = bind_listening_port_to_irqhandler(
                dev->otherend_id, xenfb_event_handler, 0, "xenfb", info);
-       if (ret < 0) {
-               xenbus_dev_fatal(dev, ret,
+       if (irq < 0) {
+               xenbus_dev_fatal(dev, irq,
                                 "bind_listening_port_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));
@@ -773,15 +772,18 @@ static int xenfb_connect_backend(struct 
                if (ret == -EAGAIN)
                        goto again;
                xenbus_dev_fatal(dev, ret, "completing transaction");
-               return ret;
+               goto unbind_irq;
        }
 
+       info->irq = irq;
        xenbus_switch_state(dev, XenbusStateInitialised);
        return 0;
 
  error_xenbus:
        xenbus_transaction_end(xbt, 1);
        xenbus_dev_fatal(dev, ret, "writing xenstore");
+ unbind_irq:
+       unbind_from_irqhandler(irq, info);
        return ret;
 }
 



Attachment: fbfront-connect-leak.patch
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] linux-2.6.18/fb: fix potential memory leak, Jan Beulich <=