From owner-p4-projects@FreeBSD.ORG Mon Dec 1 11:21:10 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9532E106567A; Mon, 1 Dec 2008 11:21:09 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 549881065670 for ; Mon, 1 Dec 2008 11:21:09 +0000 (UTC) (envelope-from weongyo@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 4071D8FC32 for ; Mon, 1 Dec 2008 11:21:09 +0000 (UTC) (envelope-from weongyo@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id mB1BL9KJ033109 for ; Mon, 1 Dec 2008 11:21:09 GMT (envelope-from weongyo@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id mB1BL9sI033107 for perforce@freebsd.org; Mon, 1 Dec 2008 11:21:09 GMT (envelope-from weongyo@FreeBSD.org) Date: Mon, 1 Dec 2008 11:21:09 GMT Message-Id: <200812011121.mB1BL9sI033107@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to weongyo@FreeBSD.org using -f From: Weongyo Jeong To: Perforce Change Reviews Cc: Subject: PERFORCE change 153880 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Dec 2008 11:21:10 -0000 http://perforce.freebsd.org/chv.cgi?CH=153880 Change 153880 by weongyo@weongyo_ws on 2008/12/01 11:20:36 - fix a panic when IRP cancel is invoked after detaching. - after returning IRP cancel routine there's no any guarantee that IRP structure is maintained at memory so we shouldn't pass IRP pointer. Affected files ... .. //depot/projects/ndisusb/sys/compat/ndis/subr_usbd.c#16 edit .. //depot/projects/ndisusb/sys/compat/ndis/usbd_var.h#4 edit Differences ... ==== //depot/projects/ndisusb/sys/compat/ndis/subr_usbd.c#16 (text+ko) ==== @@ -48,7 +48,7 @@ #include #include #include - +#include #include #include @@ -603,22 +603,17 @@ void *priv; { struct ndisusb_cancel *nc = priv; - irp *ip = nc->ip; - device_t dev = IRP_NDIS_DEV(ip); - struct ndis_softc *sc = device_get_softc(dev); - struct usb_attach_arg *uaa = device_get_ivars(dev); + struct ndis_softc *sc = device_get_softc(nc->dev); usbd_status status; - usbd_xfer_handle xfer; - usb_rem_task(uaa->device, &nc->task); - free(priv, M_USBDEV); + if (sc->ndisusb_status & NDISUSB_STATUS_DETACH) + goto exit; - xfer = IRP_NDISUSB_XFER(ip); - IRP_NDISUSB_XFER(ip) = NULL; - status = usbd_abort_pipe(sc->ndisusb_ep[NDISUSB_ENDPT_IIN]); if (status != USBD_NORMAL_COMPLETION) - device_printf(dev, "IIN can't be canceld"); + device_printf(nc->dev, "IIN can't be canceld"); +exit: + free(nc, M_USBDEV); } static int32_t @@ -638,8 +633,11 @@ return (-1); } - nc->ip = ip; + nc->dev = dev; + nc->xfer = IRP_NDISUSB_XFER(ip); usb_init_task(&nc->task, usbd_irpcancel_iin_cb, nc); + + IRP_NDISUSB_XFER(ip) = NULL; usb_add_task(uaa->device, &nc->task, USB_TASKQ_DRIVER); IoReleaseCancelSpinLock(ip->irp_cancelirql); @@ -797,21 +795,18 @@ void *priv; { struct ndisusb_cancel *nc = priv; - irp *ip = nc->ip; - device_t dev = IRP_NDIS_DEV(ip); - struct usb_attach_arg *uaa = device_get_ivars(dev); + struct ndis_softc *sc = device_get_softc(nc->dev); usbd_status status; - usbd_xfer_handle xfer; + usbd_xfer_handle xfer = nc->xfer; - usb_rem_task(uaa->device, &nc->task); - free(priv, M_USBDEV); + if (sc->ndisusb_status & NDISUSB_STATUS_DETACH) + goto exit; - xfer = IRP_NDISUSB_XFER(ip); - IRP_NDISUSB_XFER(ip) = NULL; - status = usbd_abort_pipe(xfer->pipe); if (status != USBD_NORMAL_COMPLETION) - device_printf(dev, "can't be canceld"); + device_printf(nc->dev, "can't be canceld"); +exit: + free(nc, M_USBDEV); } static int32_t @@ -847,8 +842,11 @@ return (-1); } - nc->ip = ip; + nc->dev = dev; + nc->xfer = IRP_NDISUSB_XFER(ip); usb_init_task(&nc->task, usbd_irpcancel_cb, nc); + + IRP_NDISUSB_XFER(ip) = NULL; usb_add_task(uaa->device, &nc->task, USB_TASKQ_DRIVER); IoReleaseCancelSpinLock(ip->irp_cancelirql); ==== //depot/projects/ndisusb/sys/compat/ndis/usbd_var.h#4 (text+ko) ==== @@ -189,8 +189,9 @@ /* used for IRP cancel. */ struct ndisusb_cancel { + device_t dev; + usbd_xfer_handle xfer; struct usb_task task; - irp *ip; }; extern image_patch_table usbd_functbl[];