mirror of
https://github.com/apache/nuttx.git
synced 2026-02-07 13:32:55 +08:00
When the receive buffer is full and the driver only implements recvbuf operation without receive operation, the code would crash due to calling a NULL function pointer. This patch fixes the issue by: 1. Check if recvbuf is available before calling it 2. When buffer is full, use a temporary buffer to drain hardware FIFO to prevent data accumulation in hardware 3. Add proper NULL check for receive operation to avoid crash 4. Initialize pbuf to NULL to prevent uninitialized variable usage This ensures the serial driver works correctly even when only recvbuf is implemented and the receive buffer is full. Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>