diff --git a/components/drivers/serial/serial_v2.c b/components/drivers/serial/serial_v2.c index 1d7a556bf2..5d6f2a8be3 100644 --- a/components/drivers/serial/serial_v2.c +++ b/components/drivers/serial/serial_v2.c @@ -684,6 +684,9 @@ static rt_err_t rt_serial_tx_enable(struct rt_device *dev, (sizeof(struct rt_serial_tx_fifo)); RT_ASSERT(tx_fifo != RT_NULL); + /* Init rb.buffer_ptr to RT_NULL, in rt_serial_write() need check it + * otherwise buffer_ptr maybe a random value, as rt_malloc not init memory */ + tx_fifo->rb.buffer_ptr = RT_NULL; serial->serial_tx = tx_fifo; #ifndef RT_USING_DEVICE_OPS diff --git a/components/drivers/usb/usbdevice/class/cdc_vcom.c b/components/drivers/usb/usbdevice/class/cdc_vcom.c index 0d65b0cdc5..b513394364 100644 --- a/components/drivers/usb/usbdevice/class/cdc_vcom.c +++ b/components/drivers/usb/usbdevice/class/cdc_vcom.c @@ -755,7 +755,11 @@ static rt_ssize_t _vcom_rb_block_put(struct vcom *data, const rt_uint8_t *buf, r return size; } -static rt_ssize_t _vcom_tx(struct rt_serial_device *serial, rt_uint8_t *buf, rt_size_t size, int direction) +#ifdef RT_USING_SERIAL_V1 +static rt_size_t _vcom_tx(struct rt_serial_device *serial, rt_uint8_t *buf, rt_size_t size, int direction) +#else +static rt_size_t _vcom_tx(struct rt_serial_device *serial, rt_uint8_t *buf, rt_size_t size, rt_uint32_t tx_flag) +#endif { struct ufunction *func; struct vcom *data;