summaryrefslogtreecommitdiff
path: root/components/drivers
diff options
context:
space:
mode:
authorkkangdom <[email protected]>2023-05-09 10:02:11 +0800
committerGitHub <[email protected]>2023-05-09 10:02:11 +0800
commit3cf07f1a62088245f15ee41b2e0a1df3711c1507 (patch)
treeeedab3bf180069d4dcb59e08343cb171e2a0f83f /components/drivers
parent4ce116dae0831c3069c418a131775b7ee55584c9 (diff)
[components][rndis.c] add a checkout procedure after malloc to make sure allocating successfully (#7460)
Diffstat (limited to 'components/drivers')
-rw-r--r--components/drivers/usb/usbdevice/class/rndis.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/components/drivers/usb/usbdevice/class/rndis.c b/components/drivers/usb/usbdevice/class/rndis.c
index cd57933daa..1fe48c7e9d 100644
--- a/components/drivers/usb/usbdevice/class/rndis.c
+++ b/components/drivers/usb/usbdevice/class/rndis.c
@@ -1331,6 +1331,13 @@ ufunction_t rt_usbd_function_rndis_create(udevice_t device)
cdc = rt_usbd_function_new(device, &_dev_desc, &ops);
rt_usbd_device_set_qualifier(device, &dev_qualifier);
_rndis= rt_malloc(sizeof(struct rt_rndis_eth));
+
+ if(_rndis == RT_NULL)
+ {
+ LOG_E("%s,%d: no memory!", __func__, __LINE__);
+ return RT_NULL;
+ }
+
rt_memset(_rndis, 0, sizeof(struct rt_rndis_eth));
cdc->user_data = _rndis;