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-changelog

[Xen-changelog] [linux-2.6.18-xen] xen/fb: fix potential memory leak

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [linux-2.6.18-xen] xen/fb: fix potential memory leak
From: "Xen patchbot-linux-2.6.18-xen" <patchbot@xxxxxxx>
Date: Wed, 09 Feb 2011 01:05:05 -0800
Delivery-date: Wed, 09 Feb 2011 01:05:18 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxxxx>
# Date 1297241969 0
# Node ID 350c17abbc171cff0227b4ee9131f32851ea4f37
# Parent  f6bae96cb09472afa9b3b1bd0e6ed2996b33713b
xen/fb: fix potential memory leak

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>
---
 drivers/xen/fbfront/xenfb.c |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

diff -r f6bae96cb094 -r 350c17abbc17 drivers/xen/fbfront/xenfb.c
--- a/drivers/xen/fbfront/xenfb.c       Wed Feb 09 08:38:55 2011 +0000
+++ b/drivers/xen/fbfront/xenfb.c       Wed Feb 09 08:59:29 2011 +0000
@@ -735,23 +735,22 @@ static int xenfb_connect_backend(struct 
 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;
-       }
-       info->irq = ret;
+               return irq;
+       }
 
  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;
 }
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [linux-2.6.18-xen] xen/fb: fix potential memory leak, Xen patchbot-linux-2.6.18-xen <=