[PATCH] block: check if zone_wplugs_hash exists in queue_zone_wplugs_show

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <czhong@xxxxxxxxxx>
Fixes: a98b05b02f0f ("block: Replace zone_wlock debugfs entry with zone_wplugs entry")
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@xxxxxxx>
---
 block/blk-zoned.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 3a796420f240..bad68277c0b2 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -1774,6 +1774,9 @@ int queue_zone_wplugs_show(void *data, struct seq_file *m)
 	unsigned int zwp_bio_list_size, i;
 	unsigned long flags;
 
+	if (!disk->zone_wplugs_hash)
+		return 0;
+
 	rcu_read_lock();
 	for (i = 0; i < disk_zone_wplugs_hash_size(disk); i++) {
 		hlist_for_each_entry_rcu(zwplug,
-- 
2.43.0





[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux