Commit ba16ddfb authored by piaojun's avatar piaojun Committed by Linus Torvalds
Browse files

ocfs2/o2hb: check len for bio_add_page() to avoid getting incorrect bio

We need to check len for bio_add_page() to make sure the bio has been
set up correctly, otherwise we may submit incorrect data to device.


Signed-off-by: default avatarJun Piao <>
Reviewed-by: default avatarYiwen Jiang <>
Reviewed-by: default avatarChangwei Ge <>
Acked-by: default avatarJoseph Qi <>
Cc: Mark Fasheh <>
Cc: Joel Becker <>
Cc: Junxiao Bi <>
Cc: Changwei Ge <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 39ec3774
......@@ -570,7 +570,16 @@ static struct bio *o2hb_setup_one_bio(struct o2hb_region *reg,
current_page, vec_len, vec_start);
len = bio_add_page(bio, page, vec_len, vec_start);
if (len != vec_len) break;
if (len != vec_len) {
mlog(ML_ERROR, "Adding page[%d] to bio failed, "
"page %p, len %d, vec_len %u, vec_start %u, "
"bi_sector %llu\n", current_page, page, len,
vec_len, vec_start,
(unsigned long long)bio->bi_iter.bi_sector);
bio = ERR_PTR(-EIO);
return bio;
cs += vec_len / (PAGE_SIZE/spp);
vec_start = 0;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment