Skip to content

Commit

Permalink
blkdev: check for valid request queue before issuing flush
Browse files Browse the repository at this point in the history
Issuing a blkdev_issue_flush() on an unconfigured loop device causes a panic as
q->make_request_fn is not configured. This can occur when trying to mount the
unconfigured loop device as an XFS filesystem. There are no guards that catch
the bio before the request function is called because we don't add a payload to
the bio. Instead, manually check this case as soon as we have a pointer to the
queue to flush.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
  • Loading branch information
Dave Chinner authored and Jens Axboe committed Aug 7, 2010
1 parent 2669b19 commit f10d9f6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions block/blk-barrier.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,15 @@ int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask,
if (!q)
return -ENXIO;

/*
* some block devices may not have their queue correctly set up here
* (e.g. loop device without a backing file) and so issuing a flush
* here will panic. Ensure there is a request function before issuing
* the barrier.
*/
if (!q->make_request_fn)
return -ENXIO;

bio = bio_alloc(gfp_mask, 0);
bio->bi_end_io = bio_end_empty_barrier;
bio->bi_bdev = bdev;
Expand Down

0 comments on commit f10d9f6

Please sign in to comment.