diff options
| author | Bernard Xiong <[email protected]> | 2020-09-27 08:23:55 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-09-27 08:23:55 +0800 |
| commit | aa05fc14696500620286b54c2621d07f0464cee4 (patch) | |
| tree | 66d79f95047983c310a2fe3d860bb7dc70d85ad3 | |
| parent | 08688f7095f44acc0932999767309e098e04a7e9 (diff) | |
| parent | 1703c70fd5df3fd45a2dfe302147140b15b4574a (diff) | |
Merge pull request #3675 from DavidLin1577/patch-10
[drivers/usb]Fixed a bug may cause stackover flow
| -rw-r--r-- | components/drivers/usb/usbhost/core/usbhost_core.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/components/drivers/usb/usbhost/core/usbhost_core.c b/components/drivers/usb/usbhost/core/usbhost_core.c index 71341a33c3..d72dca82f2 100644 --- a/components/drivers/usb/usbhost/core/usbhost_core.c +++ b/components/drivers/usb/usbhost/core/usbhost_core.c @@ -162,6 +162,10 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device) /* alloc memory for configuration descriptor */ device->cfg_desc = (ucfg_desc_t)rt_malloc(cfg_desc.wTotalLength); + if(device->cfg_desc == RT_NULL) + { + return RT_ENOMEM; + } rt_memset(device->cfg_desc, 0, cfg_desc.wTotalLength); /* get full configuration descriptor */ @@ -219,6 +223,10 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device) { /* allocate memory for interface device */ device->intf[i] = (struct uhintf*)rt_malloc(sizeof(struct uhintf)); + if(device->intf[i] == RT_NULL) + { + return RT_ENOMEM; + } device->intf[i]->drv = drv; device->intf[i]->device = device; device->intf[i]->intf_desc = intf_desc; |
