Re: [PATCH] can: slcan: fix freed work crash

From: Max Staudt
Date: Thu Dec 01 2022 - 14:00:24 EST


(CC: ltp@xxxxxxxxxxxxxx because Petr did so.)

Hi Jiry,

Thanks for finding this!


Your patch looks correct to me, so please have a

Reviewed-by: Max Staudt <max@xxxxxxxxx>

for both this patch to slcan, as well as an 1:1 patch to can327.



Some history:

This is actually my code from can327, which was backported to slcan as
part of Dario's larger modernisation effort.

The rationale for moving it was to flush the UART TX buffer in case of
ndo_close(), in order to bring the device into a more predictable state
between ndo_close() and ndo_open(). I guess that's actually
counterproductive - whatever is in the TX buffer at that time should
likely be fully sent. For example, can327 sends one last byte to abort
any running chatty monitoring mode from the adapter. So your patch also
fixes this as well ;)

Of course, this resulted in calling flush_worker() in both ndo_stop()
and ldisc_close(), so I wanted to avoid code duplication, and relied on
ndo_stop(). Oops.



Thanks,

Max