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;
}
fbfront-connect-leak.patch
Description: Text document
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|