Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dm: fix unlocked test for dm_suspended_md

The function dm_blk_report_zones tests if the device is suspended with
the "dm_suspended_md" call. However, this function is called without
holding any locks, so the device may be suspended just after it.

Move the call to dm_suspended_md after dm_get_live_table, so that the
device can't be suspended after the suspended state was tested.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Fixes: 37f53a2c60d0 ("dm: fix dm_blk_report_zones")
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>

+6 -3
+6 -3
drivers/md/dm-zone.c
··· 60 60 * Zone revalidation during __bind() is in progress, but this 61 61 * call is from a different process 62 62 */ 63 - if (dm_suspended_md(md)) 64 - return -EAGAIN; 65 - 66 63 map = dm_get_live_table(md, &srcu_idx); 67 64 put_table = true; 65 + 66 + if (dm_suspended_md(md)) { 67 + ret = -EAGAIN; 68 + goto do_put_table; 69 + } 68 70 } else { 69 71 /* Zone revalidation during __bind() */ 70 72 map = zone_revalidate_map; ··· 81 79 ret = dm_blk_do_report_zones(md, map, nr_zones, &dm_args); 82 80 } 83 81 82 + do_put_table: 84 83 if (put_table) 85 84 dm_put_live_table(md, srcu_idx); 86 85