Skip to content

Commit 57787fa

Browse files
morbidrsaaxboe
authored andcommitted
block: check if zone_wplugs_hash exists in queue_zone_wplugs_show
Changhui reported a kernel crash when running this simple shell reproducer: # cd /sys/kernel/debug/block && find . -type f -exec grep -aH . {} \; The above results in a NULL pointer dereference if a device does not have a zone_wplugs_hash allocated. To fix this, return early if we don't have a zone_wplugs_hash. Reported-by: Changhui Zhong <[email protected]> Fixes: a98b05b ("block: Replace zone_wlock debugfs entry with zone_wplugs entry") Signed-off-by: Johannes Thumshirn <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Link: https://lore.kernel.org/r/e5fec079dfca448cc21c425cfa5d7b291f5faa67.1714046443.git.johannes.thumshirn@wdc.com Signed-off-by: Jens Axboe <[email protected]>
1 parent a8f59e5 commit 57787fa

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

block/blk-zoned.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,6 +1774,9 @@ int queue_zone_wplugs_show(void *data, struct seq_file *m)
17741774
unsigned int zwp_bio_list_size, i;
17751775
unsigned long flags;
17761776

1777+
if (!disk->zone_wplugs_hash)
1778+
return 0;
1779+
17771780
rcu_read_lock();
17781781
for (i = 0; i < disk_zone_wplugs_hash_size(disk); i++) {
17791782
hlist_for_each_entry_rcu(zwplug,

0 commit comments

Comments
 (0)