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.

block: don't leak disk->zones_cond for !disk_need_zone_resources

disk->zones_cond is allocated for all zoned devices, but
disk_free_zone_resources skips it when the zone write plug hash is not
allocated, leaking the allocation for non-mq devices that don't emulate
zone append. This is reported by kmemleak-enabled xfstests for various
tests that use simple device mapper targets.

Fix this by moving all code that requires writes plugs from
disk_free_zone_resources into disk_destroy_zone_wplugs_hash_table
and executing the rest of the code, including the disk->zones_cond
freeing unconditionally.

Fixes: 6e945ffb6555 ("block: use zone condition to determine conventional zones")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
c6886cf6 ba13710d

+8 -12
+8 -12
block/blk-zoned.c
··· 1834 1834 kfree(disk->zone_wplugs_hash); 1835 1835 disk->zone_wplugs_hash = NULL; 1836 1836 disk->zone_wplugs_hash_bits = 0; 1837 + 1838 + /* 1839 + * Wait for the zone write plugs to be RCU-freed before destroying the 1840 + * mempool. 1841 + */ 1842 + rcu_barrier(); 1843 + mempool_destroy(disk->zone_wplugs_pool); 1844 + disk->zone_wplugs_pool = NULL; 1837 1845 } 1838 1846 1839 1847 static void disk_set_zones_cond_array(struct gendisk *disk, u8 *zones_cond) ··· 1858 1850 1859 1851 void disk_free_zone_resources(struct gendisk *disk) 1860 1852 { 1861 - if (!disk->zone_wplugs_pool) 1862 - return; 1863 - 1864 1853 if (disk->zone_wplugs_wq) { 1865 1854 destroy_workqueue(disk->zone_wplugs_wq); 1866 1855 disk->zone_wplugs_wq = NULL; 1867 1856 } 1868 1857 1869 1858 disk_destroy_zone_wplugs_hash_table(disk); 1870 - 1871 - /* 1872 - * Wait for the zone write plugs to be RCU-freed before 1873 - * destorying the mempool. 1874 - */ 1875 - rcu_barrier(); 1876 - 1877 - mempool_destroy(disk->zone_wplugs_pool); 1878 - disk->zone_wplugs_pool = NULL; 1879 1859 1880 1860 disk_set_zones_cond_array(disk, NULL); 1881 1861 disk->zone_capacity = 0;