From patchwork Thu Feb 28 12:29:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10832963 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 945E21390 for ; Thu, 28 Feb 2019 12:29:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84C812EA75 for ; Thu, 28 Feb 2019 12:29:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78E542EABB; Thu, 28 Feb 2019 12:29:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 350EC2EA75 for ; Thu, 28 Feb 2019 12:29:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731441AbfB1M3h (ORCPT ); Thu, 28 Feb 2019 07:29:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57832 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730960AbfB1M3h (ORCPT ); Thu, 28 Feb 2019 07:29:37 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1AB0130BDE4C; Thu, 28 Feb 2019 12:29:37 +0000 (UTC) Received: from localhost (ovpn-8-33.pek2.redhat.com [10.72.8.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71CD417D01; Thu, 28 Feb 2019 12:29:32 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, Ming Lei Subject: [PATCH] block: fix mp_bvec_for_each_page Date: Thu, 28 Feb 2019 20:29:27 +0800 Message-Id: <20190228122927.3495-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 28 Feb 2019 12:29:37 +0000 (UTC) Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP mp_bvec_for_each_page() may miss the 1st page in case that the bvec ends before last byte of the 1st PAGE. So fix it by checking against the last page. Fixes: 05d5585e42a399700 ("block: introduce mp_bvec_for_each_page() for iterating over page") Signed-off-by: Ming Lei --- include/linux/bvec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/bvec.h b/include/linux/bvec.h index 98a140fa4dac..85894d5000a1 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -197,7 +197,7 @@ static inline void mp_bvec_last_segment(const struct bio_vec *bvec, #define mp_bvec_for_each_page(pg, bv, i) \ for (i = (bv)->bv_offset / PAGE_SIZE; \ - (i < (((bv)->bv_offset + (bv)->bv_len) / PAGE_SIZE)) && \ + (i <= (((bv)->bv_offset + (bv)->bv_len - 1) / PAGE_SIZE)) && \ (pg = bvec_nth_page((bv)->bv_page, i)); i += 1) #endif /* __LINUX_BVEC_ITER_H */