Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1615252

Re: [PATCH 7/7] Guard bvec iteration logic v2

From Jens Axboe <axboe@kernel.dk>
Newsgroups linux.kernel
Subject Re: [PATCH 7/7] Guard bvec iteration logic v2
Date 2017-04-03 16:40 +0200
Message-ID <tsbjb-84l-5@gated-at.bofh.it> (permalink)
References <ts4B4-3Mv-5@gated-at.bofh.it> <ts4B4-3Mv-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 04/03/2017 01:23 AM, Dmitry Monakhov wrote:
> @@ -66,12 +67,15 @@ struct bvec_iter {
>  	.bv_offset	= bvec_iter_offset((bvec), (iter)),	\
>  })
>  
> -static inline void bvec_iter_advance(const struct bio_vec *bv,
> +static inline int bvec_iter_advance(const struct bio_vec *bv,
>  				     struct bvec_iter *iter,
>  				     unsigned bytes)
>  {
> -	WARN_ONCE(bytes > iter->bi_size,
> -		  "Attempted to advance past end of bvec iter\n");
> +	if(unlikely(bytes > iter->bi_size)) {
> +		WARN(1, "Attempted to advance past end of bvec iter\n");
> +		iter->bi_size = 0;
> +		return -EINVAL;
> +	}

	if (WARN_ONCE(bytes > iter->bi_size,
			"Attempted to advance past end of bvec iter\n")) {
		...

would be cleaner.

-- 
Jens Axboe

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 7/7] Guard bvec iteration logic v2 Dmitry Monakhov <dmonakhov@openvz.org> - 2017-04-03 09:30 +0200
  Re: [PATCH 7/7] Guard bvec iteration logic v2 Jens Axboe <axboe@kernel.dk> - 2017-04-03 16:40 +0200
  Re: [PATCH 7/7] Guard bvec iteration logic v2 Ming Lei <tom.leiming@gmail.com> - 2017-04-04 17:10 +0200
    Re: [PATCH 7/7] Guard bvec iteration logic v2 Dmitry Monakhov <dmonakhov@openvz.org> - 2017-04-04 17:30 +0200
      Re: [PATCH 7/7] Guard bvec iteration logic v2 Ming Lei <tom.leiming@gmail.com> - 2017-04-04 18:00 +0200

csiph-web