Commit 4e594098 authored by Milan Broz's avatar Milan Broz Committed by Alasdair G Kergon
Browse files

dm crypt: fix async inc_pending

The pending reference count must be incremented *before* the async work is
queued to another thread, not after.  Otherwise there's a race if the
work completes and decrements the reference count before it gets incremented.
Signed-off-by: default avatarMilan Broz <>
Signed-off-by: default avatarAlasdair G Kergon <>
parent 6c031f41
......@@ -719,16 +719,15 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)
remaining -= clone->bi_size;
r = crypt_convert(cc, &io->ctx);
if (atomic_dec_and_test(&io->ctx.pending)) {
/* processed, no running async crypto */
kcryptd_crypt_write_io_submit(io, r, 0);
if (unlikely(r < 0))
} else
/* out of memory -> run queues */
if (unlikely(remaining)) {
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment