• R/O
  • HTTP
  • SSH
  • HTTPS

kernel_xiaomi_msm8998: 提交

Mirror: https://github.com/0ranko0P/kernel_xiaomi_msm8998/


Commit MetaInfo

修订版354fc8ad0c0094d22481f6272294a226476ac19c (tree)
时间2020-02-15 06:30:02
作者Mike Snitzer <snitzer@redh...>
CommiterGreg Kroah-Hartman

Log Message

dm: fix potential for q->make_request_fn NULL pointer

commit 47ace7e012b9f7ad71d43ac9063d335ea3d6820b upstream.

Move blk_queue_make_request() to dm.c:alloc_dev() so that
q->make_request_fn is never NULL during the lifetime of a DM device
(even one that is created without a DM table).

Otherwise generic_make_request() will crash simply by doing:

dmsetup create -n test
mount /dev/dm-N /mnt

While at it, move ->congested_data initialization out of
dm.c:alloc_dev() and into the bio-based specific init method.

Reported-by: Stefan Bader <stefan.bader@canonical.com>
BugLink: https://bugs.launchpad.net/bugs/1860231
Fixes: ff36ab34583a ("dm: remove request-based logic from make_request_fn wrapper")
Depends-on: c12c9a3c3860c ("dm: various cleanups to md->queue initialization code")
Cc: stable@vger.kernel.org
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
[smb: adjusted for context and dm_init_md_queue() exitsting in older

kernels, and congested_data embedded in backing_dev_info, and
dm_init_normal_md_queue() was called dm_init_old_md_queue()]

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

更改概述

差异

--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -2293,7 +2293,6 @@ static void dm_init_md_queue(struct mapped_device *md)
22932293 * - must do so here (in alloc_dev callchain) before queue is used
22942294 */
22952295 md->queue->queuedata = md;
2296- md->queue->backing_dev_info.congested_data = md;
22972296 }
22982297
22992298 static void dm_init_old_md_queue(struct mapped_device *md)
@@ -2304,6 +2303,7 @@ static void dm_init_old_md_queue(struct mapped_device *md)
23042303 /*
23052304 * Initialize aspects of queue that aren't relevant for blk-mq
23062305 */
2306+ md->queue->backing_dev_info.congested_data = md;
23072307 md->queue->backing_dev_info.congested_fn = dm_any_congested;
23082308 blk_queue_bounce_limit(md->queue, BLK_BOUNCE_ANY);
23092309 }
@@ -2386,6 +2386,12 @@ static struct mapped_device *alloc_dev(int minor)
23862386 goto bad;
23872387
23882388 dm_init_md_queue(md);
2389+ /*
2390+ * default to bio-based required ->make_request_fn until DM
2391+ * table is loaded and md->type established. If request-based
2392+ * table is loaded: blk-mq will override accordingly.
2393+ */
2394+ blk_queue_make_request(md->queue, dm_make_request);
23892395
23902396 md->disk = alloc_disk(1);
23912397 if (!md->disk)
@@ -2849,7 +2855,6 @@ int dm_setup_md_queue(struct mapped_device *md)
28492855 break;
28502856 case DM_TYPE_BIO_BASED:
28512857 dm_init_old_md_queue(md);
2852- blk_queue_make_request(md->queue, dm_make_request);
28532858 /*
28542859 * DM handles splitting bios as needed. Free the bio_split bioset
28552860 * since it won't be used (saves 1 process per bio-based DM device).
Show on old repository browser