A less boneheaded patch. The only caller of uhci_device_setintr simply
returns the return value upwards and it also returns USBD_NOMEM in several
cases. So, this seems like the route of least resistance.

Thanks for the cluestick.

Index: uhci.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/uhci.c,v
retrieving revision 1.83
diff -u uhci.c
--- uhci.c 20 Sep 2010 06:54:10 -0000 1.83
+++ uhci.c 8 Oct 2010 20:06:24 -0000
@@ -2756,7 +2756,12 @@

  upipe->u.intr.npoll = npoll;
  upipe->u.intr.qhs =
- malloc(npoll * sizeof(uhci_soft_qh_t *), M_USBHC, M_WAITOK);
+ malloc(npoll * sizeof(uhci_soft_qh_t *), M_USBHC, M_NOWAIT);
+
+ if (upipe->u.intr.qhs == NULL) {
+ printf("uhci_device_setintr: unable to allocate u.intr.qhs\n");
+ return (USBD_NOMEM);
+ }

  /*
  * Figure out which offset in the schedule that has most


On Fri, Oct 8, 2010 at 8:24 AM, Bret S. Lambert <[email protected]>wrote:

> You know that you created a time bomb with this, right? Because
> that allocation can now fail, and the code doesn't test for it.

Reply via email to