mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-24 21:54:01 +00:00
serial: protect access to serial rx buffer
Add test to avoid access to rx buffer when this buffer is empty. In this case directly call getc() function to avoid issue when tstc() is not called. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
fe852bc109
commit
d3bb785854
1 changed files with 3 additions and 0 deletions
|
@ -228,6 +228,9 @@ static int _serial_getc(struct udevice *dev)
|
|||
struct serial_dev_priv *upriv = dev_get_uclass_priv(dev);
|
||||
char val;
|
||||
|
||||
if (upriv->rd_ptr == upriv->wr_ptr)
|
||||
return __serial_getc(dev);
|
||||
|
||||
val = upriv->buf[upriv->rd_ptr++];
|
||||
upriv->rd_ptr %= CONFIG_SERIAL_RX_BUFFER_SIZE;
|
||||
|
||||
|
|
Loading…
Reference in a new issue