Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753777AbdDCOee (ORCPT ); Mon, 3 Apr 2017 10:34:34 -0400 Received: from mail-it0-f50.google.com ([209.85.214.50]:35506 "EHLO mail-it0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750777AbdDCOeb (ORCPT ); Mon, 3 Apr 2017 10:34:31 -0400 Subject: Re: [PATCH 7/7] Guard bvec iteration logic v2 To: Dmitry Monakhov , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, martin.petersen@oracle.com References: <1491204212-9952-1-git-send-email-dmonakhov@openvz.org> <1491204212-9952-8-git-send-email-dmonakhov@openvz.org> From: Jens Axboe Message-ID: Date: Mon, 3 Apr 2017 08:34:28 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1491204212-9952-8-git-send-email-dmonakhov@openvz.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 733 Lines: 26 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