浏览代码

dm rq: cope with DM device destruction while in dm_old_request_fn()

Fixes a crash in dm_table_find_target() due to a NULL struct dm_table
being passed from dm_old_request_fn() that races with DM device
destruction.

Reported-by: artem@flashgrid.io
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org
Mike Snitzer 8 年之前
父节点
当前提交
4087a1fffe
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      drivers/md/dm-rq.c

+ 4 - 0
drivers/md/dm-rq.c

@@ -779,6 +779,10 @@ static void dm_old_request_fn(struct request_queue *q)
 		int srcu_idx;
 		int srcu_idx;
 		struct dm_table *map = dm_get_live_table(md, &srcu_idx);
 		struct dm_table *map = dm_get_live_table(md, &srcu_idx);
 
 
+		if (unlikely(!map)) {
+			dm_put_live_table(md, srcu_idx);
+			return;
+		}
 		ti = dm_table_find_target(map, pos);
 		ti = dm_table_find_target(map, pos);
 		dm_put_live_table(md, srcu_idx);
 		dm_put_live_table(md, srcu_idx);
 	}
 	}