linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] block: Fix bad range check in bio_sector_offset
Date: Wed, 29 Aug 2012 10:16:15 -0700	[thread overview]
Message-ID: <503E4E5F.5060003@kernel.dk> (raw)
In-Reply-To: <yq1a9xesxll.fsf@sermon.lab.mkp.net>

On 2012-08-28 11:03, Martin K. Petersen wrote:
> 
> DM would occasionally end up splitting data integrity-enabled requests
> incorrectly. The culprit was a bad range check in bio_sector_offset.
> 
> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
> Cc: <stable@vger.kernel.org>
> 
> diff --git a/fs/bio.c b/fs/bio.c
> index 9bfade8..b9a6744 100644
> --- a/fs/bio.c
> +++ b/fs/bio.c
> @@ -1552,8 +1552,8 @@ sector_t bio_sector_offset(struct bio *bio, unsigned short index,
>  	sector_sz = queue_logical_block_size(bio->bi_bdev->bd_disk->queue);
>  	sectors = 0;
>  
> -	if (index >= bio->bi_idx)
> -		index = bio->bi_vcnt - 1;
> +	if (index > bio->bi_vcnt)
> +		return 0;
>  
>  	__bio_for_each_segment(bv, bio, i, 0) {
>  		if (i == index) {

Good catch, merged.

-- 
Jens Axboe


      parent reply	other threads:[~2012-08-29 17:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-28 18:03 [PATCH] block: Fix bad range check in bio_sector_offset Martin K. Petersen
2012-08-29 14:07 ` Jeff Moyer
2012-08-29 16:19   ` Martin K. Petersen
2012-08-29 17:48     ` Jeff Moyer
2012-08-29 17:16 ` Jens Axboe [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=503E4E5F.5060003@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).