Skip to content

Commit 3047817

Browse files
klassertherbertx
authored andcommitted
padata: Fix race in the serialization path
When a padata object is queued to the serialization queue, another cpu might process and free the padata object. So don't dereference it after queueing to the serialization queue. Signed-off-by: Steffen Klassert <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 0b95ec5 commit 3047817

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

kernel/padata.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ static struct padata_priv *padata_get_next(struct parallel_data *pd)
230230

231231
static void padata_reorder(struct parallel_data *pd)
232232
{
233+
int cb_cpu;
233234
struct padata_priv *padata;
234235
struct padata_serial_queue *squeue;
235236
struct padata_instance *pinst = pd->pinst;
@@ -270,13 +271,14 @@ static void padata_reorder(struct parallel_data *pd)
270271
return;
271272
}
272273

273-
squeue = per_cpu_ptr(pd->squeue, padata->cb_cpu);
274+
cb_cpu = padata->cb_cpu;
275+
squeue = per_cpu_ptr(pd->squeue, cb_cpu);
274276

275277
spin_lock(&squeue->serial.lock);
276278
list_add_tail(&padata->list, &squeue->serial.list);
277279
spin_unlock(&squeue->serial.lock);
278280

279-
queue_work_on(padata->cb_cpu, pinst->wq, &squeue->work);
281+
queue_work_on(cb_cpu, pinst->wq, &squeue->work);
280282
}
281283

282284
spin_unlock_bh(&pd->lock);

0 commit comments

Comments
 (0)