aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/blk-map.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/block/blk-map.c b/block/blk-map.c
index 56082bea4504..caa05a667743 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -282,7 +282,8 @@ EXPORT_SYMBOL(blk_rq_unmap_user);
282 * 282 *
283 * Description: 283 * Description:
284 * Data will be mapped directly if possible. Otherwise a bounce 284 * Data will be mapped directly if possible. Otherwise a bounce
285 * buffer is used. 285 * buffer is used. Can be called multple times to append multple
286 * buffers.
286 */ 287 */
287int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf, 288int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
288 unsigned int len, gfp_t gfp_mask) 289 unsigned int len, gfp_t gfp_mask)
@@ -290,6 +291,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
290 int reading = rq_data_dir(rq) == READ; 291 int reading = rq_data_dir(rq) == READ;
291 int do_copy = 0; 292 int do_copy = 0;
292 struct bio *bio; 293 struct bio *bio;
294 int ret;
293 295
294 if (len > (q->max_hw_sectors << 9)) 296 if (len > (q->max_hw_sectors << 9))
295 return -EINVAL; 297 return -EINVAL;
@@ -311,7 +313,13 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
311 if (do_copy) 313 if (do_copy)
312 rq->cmd_flags |= REQ_COPY_USER; 314 rq->cmd_flags |= REQ_COPY_USER;
313 315
314 blk_rq_bio_prep(q, rq, bio); 316 ret = blk_rq_append_bio(q, rq, bio);
317 if (unlikely(ret)) {
318 /* request is too big */
319 bio_put(bio);
320 return ret;
321 }
322
315 blk_queue_bounce(q, &rq->bio); 323 blk_queue_bounce(q, &rq->bio);
316 rq->buffer = NULL; 324 rq->buffer = NULL;
317 return 0; 325 return 0;