On Sun, May 17, 2020 at 06:48:07PM -0700, Bart Van Assche wrote: > This patch suppresses an uninteresting KMSAN complaint without affecting > performance of the null_blk driver if CONFIG_KMSAN is disabled. > > Cc: Christoph Hellwig <hch@xxxxxx> > Cc: Ming Lei <ming.lei@xxxxxxxxxx> > Cc: Damien Le Moal <damien.lemoal@xxxxxxx> > Cc: Chaitanya Kulkarni <chaitanya.kulkarni@xxxxxxx> > Cc: Alexander Potapenko <glider@xxxxxxxxxx> > Reported-by: Alexander Potapenko <glider@xxxxxxxxxx> > Tested-by: Alexander Potapenko <glider@xxxxxxxxxx> > Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx> > --- > drivers/block/null_blk_main.c | 50 +++++++++++++++++++++++++++++++++++ > 1 file changed, 50 insertions(+) > > diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c > index 06f5761fccb6..0c1df6ecb30b 100644 > --- a/drivers/block/null_blk_main.c > +++ b/drivers/block/null_blk_main.c > @@ -1250,8 +1250,58 @@ static inline blk_status_t null_handle_memory_backed(struct nullb_cmd *cmd, > return errno_to_blk_status(err); > } > > +static void zero_fill_bvec(const struct bio_vec *bvec) > +{ > + struct page *page = bvec->bv_page; > + u32 offset = bvec->bv_offset; > + u32 left = bvec->bv_len; > + > + while (left) { > + u32 len = min_t(u32, left, PAGE_SIZE - offset); > + void *kaddr; > + > + kaddr = kmap_atomic(page); > + memset(kaddr + offset, 0, len); > + flush_dcache_page(page); > + kunmap_atomic(kaddr); > + page++; > + left -= len; > + offset = 0; > + } > +} > + > +static void nullb_zero_rq_data_buffer(const struct request *rq) > +{ > + struct req_iterator iter; > + struct bio_vec bvec; > + > + rq_for_each_bvec(bvec, rq, iter) > + zero_fill_bvec(&bvec); > +} Not necessary to add zero_fill_bvec(), and it can be done in the following two line code: __rq_for_each_bio(bio, rq) zero_fill_bio(bio); Thanks, Ming