From 085ded8eef541ee8b347468c42c359d580fcd127 Mon Sep 17 00:00:00 2001 From: ourea1429 <131341319+ourea1429@users.noreply.github.com> Date: Fri, 28 Apr 2023 21:59:42 +0800 Subject: [PATCH] [winusb.c] add checking after allocating memory for variable winusb_device to make sure allocae is successful --- components/drivers/usb/usbdevice/class/winusb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/drivers/usb/usbdevice/class/winusb.c b/components/drivers/usb/usbdevice/class/winusb.c index 906ba44169..f39dab9f06 100644 --- a/components/drivers/usb/usbdevice/class/winusb.c +++ b/components/drivers/usb/usbdevice/class/winusb.c @@ -324,6 +324,8 @@ ufunction_t rt_usbd_function_winusb_create(udevice_t device) /* allocate memory for cdc vcom data */ winusb_device = (winusb_device_t)rt_malloc(sizeof(struct winusb_device)); + if (winusb_device == NULL) + return RT_NULL; rt_memset((void *)winusb_device, 0, sizeof(struct winusb_device)); func->user_data = (void*)winusb_device; /* create an interface object */