[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c5328f91-79ec-f4f8-a9d1-bdf467e8c5f4@kernel.dk>
Date: Mon, 3 Apr 2017 08:34:28 -0600
From: Jens Axboe <axboe@...nel.dk>
To: Dmitry Monakhov <dmonakhov@...nvz.org>,
linux-kernel@...r.kernel.org, linux-block@...r.kernel.org,
martin.petersen@...cle.com
Subject: Re: [PATCH 7/7] Guard bvec iteration logic v2
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
Powered by blists - more mailing lists