diff --git a/comm/src/comm.c b/comm/src/comm.c
index 40b936217726d6bf9bb28b0f41b3541cd8431e9b..349307e8bff520091b4b38b22d6fa6aef0ff1a98 100644
--- a/comm/src/comm.c
+++ b/comm/src/comm.c
@@ -126,6 +126,8 @@ comm_error comm_receive(TComm *dev,unsigned char *data,unsigned short int *lengt
         comm_cancel_dma_receive(dev);
       else
         comm_cancel_irq_receive(dev);
+      *length=0;
+      return error;
     }
   }
   // get the received data