Is it necessary to add NULL check after calling CreateDeviceNode


wenyi,xie
 

Hi,all

UefiDevicePathLibCreateDeviceNode may return NULL when NodeLength is smaller than a device path header or there is not enough memory to allocate. But after calling UefiDevicePathLibCreateDeviceNode, the pointer is dereferenced without checking its value.

Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
MESSAGING_DEVICE_PATH,
MSG_VENDOR_DP,
(UINT16) sizeof (VENDOR_DEVICE_PATH));
CopyGuid (&Vendor->Guid, &gEfiVT100Guid);

As memory allocating may fail, is it nessary to check the value of Vendor before using.

Thanks
Wenyi