Skip to content

Commit 1703c70

Browse files
authored
[ drivers/usb]Fixed a bug may cause stackover flow
1 parent ce83371 commit 1703c70

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

components/drivers/usb/usbhost/core/usbhost_core.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device)
162162

163163
/* alloc memory for configuration descriptor */
164164
device->cfg_desc = (ucfg_desc_t)rt_malloc(cfg_desc.wTotalLength);
165+
if(device->cfg_desc == RT_NULL)
166+
{
167+
return RT_ENOMEM;
168+
}
165169
rt_memset(device->cfg_desc, 0, cfg_desc.wTotalLength);
166170

167171
/* get full configuration descriptor */
@@ -219,6 +223,10 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device)
219223
{
220224
/* allocate memory for interface device */
221225
device->intf[i] = (struct uhintf*)rt_malloc(sizeof(struct uhintf));
226+
if(device->intf[i] == RT_NULL)
227+
{
228+
return RT_ENOMEM;
229+
}
222230
device->intf[i]->drv = drv;
223231
device->intf[i]->device = device;
224232
device->intf[i]->intf_desc = intf_desc;

0 commit comments

Comments
 (0)