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

Reply via email to