From 25a2fe5593298b0c7438f43b9b8842009860db89 Mon Sep 17 00:00:00 2001 From: Yu Kuai Date: Wed, 13 Jul 2022 17:52:08 +0800 Subject: [PATCH] block: fix sleeping function called from invalid context in part_get_stat_info() hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I57S8D CVE: NA -------------------------------- part_get_stat_info() call mutex_lock() inside part_stat_lock(), which is wrong because part_stat_lock() disables preempt. Fix the problem by hold mutex first. Signed-off-by: Yu Kuai Reviewed-by: Jason Yan Signed-off-by: Zheng Zengkai --- block/genhd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index cc114dd0265b..fcd6210417bc 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1311,12 +1311,12 @@ static void part_get_stat_info(struct hd_struct *hd, struct disk_stats *stat, struct request_queue *q = part_to_disk(hd)->queue; if (queue_is_mq(q)) { - part_stat_lock(); mutex_lock(&part_to_dev(hd)->mutex); + part_stat_lock(); part_set_stat_time(hd); *inflight = blk_mq_in_flight_with_stat(q, hd); - mutex_unlock(&part_to_dev(hd)->mutex); part_stat_unlock(); + mutex_unlock(&part_to_dev(hd)->mutex); } else { *inflight = part_in_flight(hd); } -- GitLab