From: "Ky Srinivasan" Subject: [PATCH]: Fix some bugs in usbfront Date: Fri, 12 Mar 2010 11:25:21 -0700 Message-ID: <4B9A24A1020000300008129C@sinclair.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part3F15E301.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 --=__Part3F15E301.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline The attached patch fixes some bugs in usbfront. Signed-off-by: K. Y. Srinivasan --=__Part3F15E301.0__= Content-Type: text/plain; name="usbfront_schedule.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="usbfront_schedule.patch" Bug#584218: Fix a scheduling race in usbfront. Create the thread only = after we =0Aare connected. The current code schedules the thread at a = point where the =0Acommunication rings are not initialized yet.=0A=0ASigned= -off-by: K. Y. Srinivasan =0A=0AIndex: linux/driver= s/xen/usbfront/xenbus.c=0A=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=0A--- linux.orig/drivers/xen/usbfront/xenbus.c 2010-03-10 = 12:10:58.000000000 -0700=0A+++ linux/drivers/xen/usbfront/xenbus.c = 2010-03-10 12:17:24.000000000 -0700=0A@@ -192,11 +192,23 @@ static int = connect(struct xenbus_device=0A usbif_conn_request_t *req;=0A = int i, idx, err;=0A int notify;=0A+ char name[TASK_COMM_LEN];=0A+ = struct usb_hcd *hcd;=0A+=0A+ hcd =3D info_to_hcd(info);=0A+ snprintf(na= me, TASK_COMM_LEN, "xenhcd.%d", hcd->self.busnum);=0A =0A err =3D = talk_to_backend(dev, info);=0A if (err)=0A return err;=0A = =0A+ info->kthread =3D kthread_run(xenhcd_schedule, info, name);=0A+ if = (IS_ERR(info->kthread)) {=0A+ err =3D PTR_ERR(info->kthread);=0A+= info->kthread =3D NULL;=0A+ xenbus_dev_fatal(de= v, err, "Error creating thread");=0A+ return err;=0A+ }=0A /* = prepare ring for hotplug notification */=0A for (idx =3D 0, i =3D 0; i = < USB_CONN_RING_SIZE; i++) {=0A req =3D RING_GET_REQUEST(&i= nfo->conn_ring, idx);=0A@@ -274,7 +286,6 @@ static int usbfront_probe(struc= t xenbus_=0A int err;=0A struct usb_hcd *hcd;=0A struct = usbfront_info *info;=0A- char name[TASK_COMM_LEN];=0A =0A if = (usb_disabled())=0A return -ENODEV;=0A@@ -298,13 +309,6 @@ = static int usbfront_probe(struct xenbus_=0A }=0A =0A init_waitqu= eue_head(&info->wq);=0A- snprintf(name, TASK_COMM_LEN, "xenhcd.%d", = hcd->self.busnum);=0A- info->kthread =3D kthread_run(xenhcd_schedule, = info, name);=0A- if (IS_ERR(info->kthread)) {=0A- = err =3D PTR_ERR(info->kthread);=0A- info->kthread =3D = NULL;=0A- goto fail;=0A- }=0A =0A return 0;=0A =0A@@ = -343,8 +347,8 @@ static void backend_changed(struct xenbu=0A case = XenbusStateInitWait:=0A if (dev->state !=3D XenbusStateInit= ialising)=0A break;=0A- connect(dev);=0A- = xenbus_switch_state(dev, XenbusStateConnected);=0A+ if = (!connect(dev))=0A+ xenbus_switch_state(dev, XenbusStat= eConnected);=0A break;=0A =0A case XenbusStateClosing:=0A --=__Part3F15E301.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 --=__Part3F15E301.0__=--