Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ffcc89db authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Greg Kroah-Hartman
Browse files

dm thin: fix a race in thin_dtr



commit 17181fb7a0c3a279196c0eeb2caba65a1519614b upstream.

As long as struct thin_c is in the list, anyone can grab a reference of
it.  Consequently, we must wait for the reference count to drop to zero
*after* we remove the structure from the list, not before.

Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2409f513
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -3266,14 +3266,14 @@ static void thin_dtr(struct dm_target *ti)
	struct thin_c *tc = ti->private;
	unsigned long flags;

	thin_put(tc);
	wait_for_completion(&tc->can_destroy);

	spin_lock_irqsave(&tc->pool->lock, flags);
	list_del_rcu(&tc->list);
	spin_unlock_irqrestore(&tc->pool->lock, flags);
	synchronize_rcu();

	thin_put(tc);
	wait_for_completion(&tc->can_destroy);

	mutex_lock(&dm_thin_pool_table.mutex);

	__pool_dec(tc->pool);