[PATCH] block: break loop when getting target major number in blkdev_show()

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

 



The entry in major_names table has unique major number,
so there is no need to continue to search after getting
target major number in blkdev_show().

Signed-off-by: Chengguang Xu <cgxu519@xxxxxxx>
---
 block/genhd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/block/genhd.c b/block/genhd.c
index 1dd8fd6613b8..908e3b4399a3 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -324,8 +324,10 @@ void blkdev_show(struct seq_file *seqf, off_t offset)
 
 	mutex_lock(&block_class_lock);
 	for (dp = major_names[major_to_index(offset)]; dp; dp = dp->next)
-		if (dp->major == offset)
+		if (dp->major == offset) {
 			seq_printf(seqf, "%3d %s\n", dp->major, dp->name);
+			break;
+		}
 	mutex_unlock(&block_class_lock);
 }
 #endif /* CONFIG_PROC_FS */
-- 
2.17.2




[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