diff options
author | Mike Snitzer <snitzer@kernel.org> | 2023-02-17 21:08:17 +0300 |
---|---|---|
committer | Mike Snitzer <snitzer@kernel.org> | 2023-02-17 22:49:21 +0300 |
commit | 69868bebfe8e9a47b0d8a12f7473b8a3b7239ef3 (patch) | |
tree | 233cdb247d0448a000d1a89ea2b33daa5776a4b3 | |
parent | 76227f6dc805e9e960128bcc6276647361e0827c (diff) | |
download | linux-69868bebfe8e9a47b0d8a12f7473b8a3b7239ef3.tar.xz |
dm ioctl: assert _hash_lock is held in __hash_remove
Also update dm_early_create() to take _hash_lock when calling both
__get_name_cell and __hash_remove -- given dm_early_create()'s early
boot usecase this locking isn't about correctness but it allows
lockdep_assert_held() to be added to __hash_remove.
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
-rw-r--r-- | drivers/md/dm-ioctl.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index f34d36a4b4a1..067dfc08d4c3 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -310,6 +310,8 @@ static struct dm_table *__hash_remove(struct hash_cell *hc) struct dm_table *table; int srcu_idx; + lockdep_assert_held(&_hash_lock); + /* remove from the dev trees */ __unlink_name(hc); __unlink_uuid(hc); @@ -2263,7 +2265,9 @@ int __init dm_early_create(struct dm_ioctl *dmi, err_destroy_table: dm_table_destroy(t); err_hash_remove: + down_write(&_hash_lock); (void) __hash_remove(__get_name_cell(dmi->name)); + up_write(&_hash_lock); /* release reference from __get_name_cell */ dm_put(md); err_destroy_dm: |