From: "Jan Beulich" Subject: [PATCH] linux-2.6.18/fb: fix potential memory leak Date: Tue, 08 Feb 2011 17:15:51 +0000 Message-ID: <4D5188570200007800030D3F@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part59754857.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part59754857.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline From: Joe Jin 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 Signed-off-by: Joe Jin Tested-by: Gurudas Pai Acked-by: Ian Campbell Made apply to linux-2.6.18-xen.hg. Signed-off-by: Jan Beulich --- 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; =20 - ret =3D bind_listening_port_to_irqhandler( + irq =3D 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 =3D ret; =20 again: ret =3D xenbus_transaction_start(&xbt); if (ret) { xenbus_dev_fatal(dev, ret, "starting transaction"); - return ret; + goto unbind_irq; } ret =3D xenbus_printf(xbt, dev->nodename, "page-ref", "%lu", virt_to_mfn(info->page)); @@ -773,15 +772,18 @@ static int xenfb_connect_backend(struct=20 if (ret =3D=3D -EAGAIN) goto again; xenbus_dev_fatal(dev, ret, "completing transaction"); - return ret; + goto unbind_irq; } =20 + info->irq =3D irq; xenbus_switch_state(dev, XenbusStateInitialised); return 0; =20 error_xenbus: xenbus_transaction_end(xbt, 1); xenbus_dev_fatal(dev, ret, "writing xenstore"); + unbind_irq: + unbind_from_irqhandler(irq, info); return ret; } =20 --=__Part59754857.0__= Content-Type: text/plain; name="fbfront-connect-leak.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="fbfront-connect-leak.patch" From: Joe Jin =0ASubject: xen/fb: fix potential memory = leak=0A=0AThis patch fixes a potential memory leak when xenfb connect = to=0Athe backend fails.=0A=0AThanks for Ian's review and comments.=0A=0A[v2= : reworded the commit message a bit]=0A=0ASigned-off-by: Konrad Rzeszutek = Wilk =0ASigned-off-by: Joe Jin = =0ATested-by: Gurudas Pai =0AAcked-by: Ian = Campbell =0A=0AMade apply to linux-2.6.18-xen.hg.= =0A=0ASigned-off-by: Jan Beulich =0A=0A--- a/drivers/x= en/fbfront/xenfb.c=0A+++ b/drivers/xen/fbfront/xenfb.c=0A@@ -735,23 = +735,22 @@ static void xenfb_init_shared_page(struc=0A static int = xenfb_connect_backend(struct xenbus_device *dev,=0A = struct xenfb_info *info)=0A {=0A- int ret;=0A+ int ret, irq;=0A = struct xenbus_transaction xbt;=0A =0A- ret =3D bind_listening_port_to_irqh= andler(=0A+ irq =3D bind_listening_port_to_irqhandler(=0A = dev->otherend_id, xenfb_event_handler, 0, "xenfb", info);=0A- if (ret < = 0) {=0A- xenbus_dev_fatal(dev, ret,=0A+ if (irq < 0) {=0A+ = xenbus_dev_fatal(dev, irq,=0A "bind_list= ening_port_to_irqhandler");=0A- return ret;=0A+ return = irq;=0A }=0A- info->irq =3D ret;=0A =0A again:=0A ret =3D = xenbus_transaction_start(&xbt);=0A if (ret) {=0A xenbus_dev_= fatal(dev, ret, "starting transaction");=0A- return ret;=0A+ = goto unbind_irq;=0A }=0A ret =3D xenbus_printf(xbt, dev->nodename, = "page-ref", "%lu",=0A virt_to_mfn(info->page));=0A@@ = -773,15 +772,18 @@ static int xenfb_connect_backend(struct =0A if = (ret =3D=3D -EAGAIN)=0A goto again;=0A = xenbus_dev_fatal(dev, ret, "completing transaction");=0A- = return ret;=0A+ goto unbind_irq;=0A }=0A =0A+ info->irq = =3D irq;=0A xenbus_switch_state(dev, XenbusStateInitialised);=0A = return 0;=0A =0A error_xenbus:=0A xenbus_transaction_end(xbt, 1);=0A = xenbus_dev_fatal(dev, ret, "writing xenstore");=0A+ unbind_irq:=0A+= unbind_from_irqhandler(irq, info);=0A return ret;=0A }=0A =0A --=__Part59754857.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__Part59754857.0__=--