Re: [PATCHv2 net] usbnet: fix cyclical race on disconnect with work queue

From: Oliver Neukum
Date: Thu Sep 12 2024 - 05:31:05 EST




On 10.09.24 11:58, Paolo Abeni wrote:

I guess you do the shutdown twice because a running tasklet or timer could re-schedule the others? If so, what prevent the rescheduling to happen in the 2nd iteration? why can't you add usbnet_going_away() checks on tasklet and timer reschedule point?

Hi,

I am not sure I fully understand the question. Technically
the flag prevents it in cooperation with del_timer_sync(),
which will wait for the timer handler to run to completion.

Hence if the timer handler has passed the the check the first
time, it will see the flag the second time.
I am not sure that answers the question, because AFAICT I have
added the checks, but there is an inevitable window between
the check and acting upon it.

Regards
Oliver