diff options
| author | miaoxingr <[email protected]> | 2023-05-12 13:39:51 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-12 01:39:51 -0400 |
| commit | f36a1bb5141f6a2e5f4cfe276058104899342497 (patch) | |
| tree | 3893ca3cbf87a9b4bc27231e7854a4520f7a0595 /components | |
| parent | 9dd0d4125190907332c0510a1449c3cfdb0104bf (diff) | |
[components/drivers] add checking code after allocating memory
Diffstat (limited to 'components')
| -rw-r--r-- | components/drivers/usb/usbhost/core/hub.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/components/drivers/usb/usbhost/core/hub.c b/components/drivers/usb/usbhost/core/hub.c index 314ec627a1..549fe373d4 100644 --- a/components/drivers/usb/usbhost/core/hub.c +++ b/components/drivers/usb/usbhost/core/hub.c @@ -14,6 +14,11 @@ #define USB_THREAD_STACK_SIZE 4096 +#define DBG_TAG "usbhost.hub" +#define DBG_LVL DBG_INFO +#include <rtdbg.h> + + // static struct rt_messagequeue *usb_mq; static struct uclass_driver hub_driver; // static struct uhub root_hub; @@ -702,6 +707,11 @@ void rt_usbh_hub_init(uhcd_t hcd) rt_thread_t thread; /* create root hub for hcd */ hcd->roothub = rt_malloc(sizeof(struct uhub)); + if(hcd->roothub == RT_NULL) + { + LOG_E("hcd->roothub: allocate buffer failed."); + return; + } rt_memset(hcd->roothub, 0, sizeof(struct uhub)); hcd->roothub->is_roothub = RT_TRUE; hcd->roothub->hcd = hcd; |
