]> Git Repo - linux.git/commitdiff
ocfs2/o2hb: check len for bio_add_page() to avoid getting incorrect bio
authorpiaojun <[email protected]>
Thu, 5 Apr 2018 23:19:36 +0000 (16:19 -0700)
committerLinus Torvalds <[email protected]>
Fri, 6 Apr 2018 04:36:22 +0000 (21:36 -0700)
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.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Jun Piao <[email protected]>
Reviewed-by: Yiwen Jiang <[email protected]>
Reviewed-by: Changwei Ge <[email protected]>
Acked-by: Joseph Qi <[email protected]>
Cc: Mark Fasheh <[email protected]>
Cc: Joel Becker <[email protected]>
Cc: Junxiao Bi <[email protected]>
Cc: Changwei Ge <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
fs/ocfs2/cluster/heartbeat.c

index ea8c551bcd7e4302f5b460a3c145ef2dbf0d4398..91a8889abf9ba9f4d3df399996346942f48c2555 100644 (file)
@@ -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_put(bio);
+                       bio = ERR_PTR(-EIO);
+                       return bio;
+               }
 
                cs += vec_len / (PAGE_SIZE/spp);
                vec_start = 0;
This page took 0.067702 seconds and 4 git commands to generate.