Re: [PATCH] cangen: flush the CAN frame at each iteration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



- linux-kernel@xxxxxxxxxxxxxxx
+ linux-can@xxxxxxxxxxxxxxx

Wrong mailing list ...

On 01.11.20 15:57, Vincent Mailhol wrote:
The variable 'frame' is declared on the stack and is reused at each
iteration of the while loop.

If not flushed, garbage data from the previous iteration of the loop
could remain causing unexpected behavior. This is the case in DLC
random mode: the field frame.len8_dlc is not cleared when the dlc is
exactly 8 and the len8_dlc value of the previous iteration will be
sent again.

Good catch! Thanks.

This can be observed by running 'cangen -8 can0'. Once a frame of DLC
in the range 9..15 is generated, no more frames of DLC 8 show out in
the log.

Signed-off-by: Vincent Mailhol <mailhol.vincent@xxxxxxxxxx>
---
  cangen.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cangen.c b/cangen.c
index ab8122c..d7392b6 100644
--- a/cangen.c
+++ b/cangen.c
@@ -384,7 +384,7 @@ int main(int argc, char **argv)
  	}
while (running) {
-		frame.flags = 0;
+		memset(&frame, 0, sizeof(frame));

But this patch breaks everything which is not in random mode.

Analogue to frame.flags we just need to clear frame.len8_dlc

Regards,
Oliver

if (count && (--count == 0))
  			running = 0;




[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux