In zloop_report_zones(), filling the write pointer and condition of a zone descriptor separately outside of the zone wp_lock can lead to an inconsistent zone report with a write pointer potentially not being consistent with the condition being reported. Avoid such inconsistency by filling both fields while holding the zone wp_lock. Fixes: fcc6eaa3a03a ("zloop: introduce the ordered_zone_append configuration parameter") Signed-off-by: Damien Le Moal Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig --- drivers/block/zloop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c index 19949ed3824f..6bb68022ab30 100644 --- a/drivers/block/zloop.c +++ b/drivers/block/zloop.c @@ -950,8 +950,8 @@ static int zloop_report_zones(struct gendisk *disk, sector_t sector, blkz.len = zlo->zone_size; spin_lock(&zone->wp_lock); blkz.wp = zone->wp; - spin_unlock(&zone->wp_lock); blkz.cond = zone->cond; + spin_unlock(&zone->wp_lock); if (test_bit(ZLOOP_ZONE_CONV, &zone->flags)) { blkz.type = BLK_ZONE_TYPE_CONVENTIONAL; blkz.capacity = zlo->zone_size; -- 2.56.1