[components][rndis.c] add a checkout procedure after malloc to make sure allocating successfully (#7460)

This commit is contained in:
kkangdom 2023-05-09 10:02:11 +08:00 committed by GitHub
parent 4ce116dae0
commit 3cf07f1a62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -1331,6 +1331,13 @@ ufunction_t rt_usbd_function_rndis_create(udevice_t device)
cdc = rt_usbd_function_new(device, &_dev_desc, &ops); cdc = rt_usbd_function_new(device, &_dev_desc, &ops);
rt_usbd_device_set_qualifier(device, &dev_qualifier); rt_usbd_device_set_qualifier(device, &dev_qualifier);
_rndis= rt_malloc(sizeof(struct rt_rndis_eth)); _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)); rt_memset(_rndis, 0, sizeof(struct rt_rndis_eth));
cdc->user_data = _rndis; cdc->user_data = _rndis;