On 2/11/22 21:51, John Garry wrote: > On 11/02/2022 07:37, Damien Le Moal wrote: > > Hi Damien, > >> The n_elem local variable in pm8001_task_exec() is initialized to 0 and >> changed set to the number of DMA scatter elements for a needed for a >> task command only for ATA commands and for SAS commands that have a >> non-zero number of sg segments. n_elem is never initialized to 0 for SAS > > Do you mean re-initialized? > > I thought the current code was ok, as we init n_elem = 0 and we only > ever loop once. Am I missing something? It was not clear to me because of the loop. If the loop is done only once, why the loop in the first place ? Hold on... Oh ! It is a while(0)... OK, this too ugly to live. We need to do something about this. The continue at the beginning of the loop seems totally crazy as it may lead to the same task being reused, so multiple ->task_done() calls for the same task. Is that sane ? -- Damien Le Moal Western Digital Research