From patchwork Wed Sep 20 11:43:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manos Pitsidianakis X-Patchwork-Id: 9961503 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 07B8560234 for ; Wed, 20 Sep 2017 14:04:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED312290D1 for ; Wed, 20 Sep 2017 14:04:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1E66290E4; Wed, 20 Sep 2017 14:04:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6ABB5290D1 for ; Wed, 20 Sep 2017 14:04:02 +0000 (UTC) Received: from localhost ([::1]:48284 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dufbd-0008TL-IY for patchwork-qemu-devel@patchwork.kernel.org; Wed, 20 Sep 2017 10:04:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41757) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dufAW-00024b-Qe for qemu-devel@nongnu.org; Wed, 20 Sep 2017 09:36:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dufAS-00011k-Sx for qemu-devel@nongnu.org; Wed, 20 Sep 2017 09:36:00 -0400 Received: from smtp1.ntua.gr ([2001:648:2000:de::183]:20570) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dufAK-0000sM-51; Wed, 20 Sep 2017 09:35:48 -0400 Received: from mail.ntua.gr (carp0.noc.ntua.gr [147.102.222.60]) (authenticated bits=0) by smtp1.ntua.gr (8.15.2/8.15.2) with ESMTPSA id v8KBhZCv074332 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Sep 2017 14:43:35 +0300 (EEST) (envelope-from el13635@mail.ntua.gr) X-Authentication-Warning: smtp1.ntua.gr: Host carp0.noc.ntua.gr [147.102.222.60] claimed to be mail.ntua.gr From: Manos Pitsidianakis To: qemu-devel Date: Wed, 20 Sep 2017 14:43:09 +0300 Message-Id: <20170920114310.13080-2-el13635@mail.ntua.gr> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170920114310.13080-1-el13635@mail.ntua.gr> References: <20170920114310.13080-1-el13635@mail.ntua.gr> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:648:2000:de::183 Subject: [Qemu-devel] [PATCH 1/2] block/block-backend.c: add blk_check_byte_request call to blk_pread/blk_pwrite X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , John Snow , qemu-block , Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP blk_check_byte_request() is called from the blk_co_pwritev/blk_co_preadv to check if the request offset and request bytes parameters are valid for the given Blockbackend. Let's do that in blk_pread/blk_pwrite too. Signed-off-by: Manos Pitsidianakis --- block/block-backend.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 45d9101be3..110a52d5b1 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1288,22 +1288,23 @@ BlockAIOCB *blk_aio_pwrite_zeroes(BlockBackend *blk, int64_t offset, int blk_pread(BlockBackend *blk, int64_t offset, void *buf, int count) { - int ret = blk_prw(blk, offset, buf, count, blk_read_entry, 0); + int ret = blk_check_byte_request(blk, offset, count); if (ret < 0) { return ret; } - return count; + ret = blk_prw(blk, offset, buf, count, blk_read_entry, 0); + return ret < 0 ? ret : count; } int blk_pwrite(BlockBackend *blk, int64_t offset, const void *buf, int count, BdrvRequestFlags flags) { - int ret = blk_prw(blk, offset, (void *) buf, count, blk_write_entry, - flags); + int ret = blk_check_byte_request(blk, offset, count); if (ret < 0) { return ret; } - return count; + ret = blk_prw(blk, offset, (void *) buf, count, blk_write_entry, flags); + return ret < 0 ? ret : count; } int64_t blk_getlength(BlockBackend *blk)