summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2020-03-26 22:06:23 +0800
committerGitHub <[email protected]>2020-03-26 22:06:23 +0800
commit7f6755c622fd76394f0496752d7b33846f19ebe8 (patch)
tree5671d1135cdecf6fb23ca8689dbad4bf87dcf413 /components
parentc1a3de7b8a6fdc279ddaa5c83d169bb8ab1cdf53 (diff)
parent985a70ab155da7bc06635409f0ab5e6c8a6561a0 (diff)
Merge pull request #3472 from DavidLin1577/patch-2
[components/usb]Fixed a stack overflow bug
Diffstat (limited to 'components')
-rw-r--r--components/drivers/usb/usbdevice/class/cdc_vcom.c2
-rw-r--r--components/drivers/usb/usbdevice/class/ecm.c3
-rw-r--r--components/drivers/usb/usbhost/core/hub.c1
3 files changed, 5 insertions, 1 deletions
diff --git a/components/drivers/usb/usbdevice/class/cdc_vcom.c b/components/drivers/usb/usbdevice/class/cdc_vcom.c
index c94a438131..c4fc3b0ad9 100644
--- a/components/drivers/usb/usbdevice/class/cdc_vcom.c
+++ b/components/drivers/usb/usbdevice/class/cdc_vcom.c
@@ -493,6 +493,7 @@ static rt_err_t _function_enable(ufunction_t func)
data = (struct vcom*)func->user_data;
data->ep_out->buffer = rt_malloc(CDC_RX_BUFSIZE);
+ RT_ASSERT(data->ep_out->buffer != RT_NULL);
data->ep_out->request.buffer = data->ep_out->buffer;
data->ep_out->request.size = EP_MAXPACKET(data->ep_out);
@@ -593,6 +594,7 @@ ufunction_t rt_usbd_function_cdc_create(udevice_t device)
/* allocate memory for cdc vcom data */
data = (struct vcom*)rt_malloc(sizeof(struct vcom));
+ RT_ASSERT(data != RT_NULL);
rt_memset(data, 0, sizeof(struct vcom));
func->user_data = (void*)data;
diff --git a/components/drivers/usb/usbdevice/class/ecm.c b/components/drivers/usb/usbdevice/class/ecm.c
index cf948adbfc..36557dad74 100644
--- a/components/drivers/usb/usbdevice/class/ecm.c
+++ b/components/drivers/usb/usbdevice/class/ecm.c
@@ -565,7 +565,8 @@ ufunction_t rt_usbd_function_ecm_create(udevice_t device)
/* create a cdc class */
cdc = rt_usbd_function_new(device, &_dev_desc, &ops);
rt_usbd_device_set_qualifier(device, &dev_qualifier);
- _ecm_eth= rt_malloc(sizeof(struct rt_ecm_eth));
+ _ecm_eth= rt_malloc(sizeof(struct rt_ecm_eth));
+ RT_ASSERT(_ecm_eth != RT_NULL);
rt_memset(_ecm_eth, 0, sizeof(struct rt_ecm_eth));
cdc->user_data = _ecm_eth;
diff --git a/components/drivers/usb/usbhost/core/hub.c b/components/drivers/usb/usbhost/core/hub.c
index 80ed9b4e3f..fb6cd9c406 100644
--- a/components/drivers/usb/usbhost/core/hub.c
+++ b/components/drivers/usb/usbhost/core/hub.c
@@ -508,6 +508,7 @@ static rt_err_t rt_usbh_hub_enable(void *arg)
/* create a hub instance */
hub = rt_malloc(sizeof(struct uhub));
+ RT_ASSERT(hub != RT_NULL);
rt_memset(hub, 0, sizeof(struct uhub));
/* make interface instance's user data point to hub instance */