Skip to content

Commit a2f998a

Browse files
Hou TaoMike Snitzer
authored andcommitted
dm ioctl: remove unnecessary check when using dm_get_mdptr()
__hash_remove() removes hash_cell with _hash_lock locked, so acquiring _hash_lock can guarantee no-NULL hc returned from dm_get_mdptr() must have not been removed and hc->md must still be md. __hash_remove() also acquires dm_hash_cells_mutex before setting mdptr as NULL. So in dm_copy_name_and_uuid(), after acquiring dm_hash_cells_mutex and ensuring returned hc is not NULL, the returned hc must still be alive and hc->md must still be md. Remove the unnecessary hc->md != md checks when using dm_get_mdptr() with _hash_lock or dm_hash_cells_mutex acquired. Signed-off-by: Hou Tao <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent 69868be commit a2f998a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/md/dm-ioctl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ static struct dm_table *dm_get_inactive_table(struct mapped_device *md, int *src
789789

790790
down_read(&_hash_lock);
791791
hc = dm_get_mdptr(md);
792-
if (!hc || hc->md != md) {
792+
if (!hc) {
793793
DMERR("device has been removed from the dev hash table.");
794794
goto out;
795795
}
@@ -1500,7 +1500,7 @@ static int table_load(struct file *filp, struct dm_ioctl *param, size_t param_si
15001500
/* stage inactive table */
15011501
down_write(&_hash_lock);
15021502
hc = dm_get_mdptr(md);
1503-
if (!hc || hc->md != md) {
1503+
if (!hc) {
15041504
DMERR("device has been removed from the dev hash table.");
15051505
up_write(&_hash_lock);
15061506
r = -ENXIO;
@@ -2152,7 +2152,7 @@ int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid)
21522152

21532153
mutex_lock(&dm_hash_cells_mutex);
21542154
hc = dm_get_mdptr(md);
2155-
if (!hc || hc->md != md) {
2155+
if (!hc) {
21562156
r = -ENXIO;
21572157
goto out;
21582158
}

0 commit comments

Comments
 (0)