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 <[email protected]>
---
 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

Reply via email to