diff --git a/drivers/usbdev/composite.c b/drivers/usbdev/composite.c index ba926697fc..3653ce1155 100644 --- a/drivers/usbdev/composite.c +++ b/drivers/usbdev/composite.c @@ -807,6 +807,8 @@ FAR void *composite_initialize(uint8_t ndevices, int ret; int i; + DEBUGASSERT(pdevices != NULL && ndevices <= NUM_DEVICES_TO_HANDLE); + /* Allocate the structures needed */ alloc = (FAR struct composite_alloc_s *) @@ -866,9 +868,10 @@ FAR void *composite_initialize(uint8_t ndevices, /* Register the USB composite class driver */ ret = usbdev_register(&drvr->drvr); - if (ret) + if (ret < 0) { - usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_DEVREGISTER), (uint16_t)-ret); + usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_DEVREGISTER), + (uint16_t)-ret); goto errout_with_alloc; } diff --git a/drivers/usbdev/composite.h b/drivers/usbdev/composite.h index 718d520b6a..d306607a2b 100644 --- a/drivers/usbdev/composite.h +++ b/drivers/usbdev/composite.h @@ -116,7 +116,7 @@ # define COMPOSITE_REMOTEWAKEUP (0) #endif -#define NUM_DEVICES_TO_HANDLE (4) +#define NUM_DEVICES_TO_HANDLE (4) /* Descriptors **************************************************************/ /* These settings are not modifiable via the NuttX configuration */