From patchwork Mon Jan 8 13:20:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 10149543 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 A6D4E601A1 for ; Mon, 8 Jan 2018 13:22:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F32628986 for ; Mon, 8 Jan 2018 13:22:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DB4B28991; Mon, 8 Jan 2018 13:22:07 +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 A6E2C28C11 for ; Mon, 8 Jan 2018 13:21:08 +0000 (UTC) Received: from localhost ([::1]:34243 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eYXMR-00010t-NL for patchwork-qemu-devel@patchwork.kernel.org; Mon, 08 Jan 2018 08:21:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36059) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eYXLY-0000Lf-99 for qemu-devel@nongnu.org; Mon, 08 Jan 2018 08:20:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eYXLU-0001F0-3s for qemu-devel@nongnu.org; Mon, 08 Jan 2018 08:20:12 -0500 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:51801 helo=mx01.kamp.de) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eYXLT-0001E7-Qb for qemu-devel@nongnu.org; Mon, 08 Jan 2018 08:20:08 -0500 Received: (qmail 10568 invoked by uid 89); 8 Jan 2018 13:20:04 -0000 Received: from [195.62.97.192] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.99.2/24202. avast: 1.2.2/17010300. spamassassin: 3.4.1. Clear:RC:1(195.62.97.192):. Processed in 0.060773 secs); 08 Jan 2018 13:20:04 -0000 Received: from kerio.kamp.de ([195.62.97.192]) by mx01.kamp.de with ESMTPS (DHE-RSA-AES256-SHA encrypted); 8 Jan 2018 13:20:04 -0000 X-GL_Whitelist: yes X-Footer: a2FtcC5kZQ== Received: from submission.kamp.de ([195.62.97.28]) by kerio.kamp.de with ESMTPS (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256 bits)) for qemu-devel@nongnu.org; Mon, 8 Jan 2018 14:20:01 +0100 Received: (qmail 1851 invoked from network); 8 Jan 2018 13:20:02 -0000 Received: from lieven-pc.kamp-intra.net (HELO ?172.21.12.60?) (pl@kamp.de@::ffff:172.21.12.60) by submission.kamp.de with ESMTPS (DHE-RSA-AES128-SHA encrypted) ESMTPA; 8 Jan 2018 13:20:02 -0000 To: Fam Zheng , qemu-devel@nongnu.org References: <20180108030946.14991-1-famz@redhat.com> From: Peter Lieven Message-ID: <30369c9b-974f-67d4-322f-00d30a25519a@kamp.de> Date: Mon, 8 Jan 2018 14:20:02 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20180108030946.14991-1-famz@redhat.com> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a02:248:0:51::16 Subject: Re: [Qemu-devel] [PATCH] scsi: Don't check uninitialized local variable 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: Paolo Bonzini , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Am 08.01.2018 um 04:09 schrieb Fam Zheng: > After the out label there is a check on iTask.task but it is not > initialized yet. > > Fixes: e38bc23454ef763deb4405ebdee6a1081aa00bc8 > Signed-off-by: Fam Zheng > --- > block/iscsi.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/block/iscsi.c b/block/iscsi.c > index 5c0a9e55b6..1cb8cc93c5 100644 > --- a/block/iscsi.c > +++ b/block/iscsi.c > @@ -659,8 +659,7 @@ static int64_t coroutine_fn iscsi_co_get_block_status(BlockDriverState *bs, > int64_t ret; > > if (!is_sector_request_lun_aligned(sector_num, nb_sectors, iscsilun)) { > - ret = -EINVAL; > - goto out; > + return -EINVAL; > } > > /* default to all sectors allocated */ If lbpme is 0 we run into the same error. And this is even more likely than an unaligned request. I think the right patch is to move the init of iTask up again where it was: Peter Reviewed-by: Eric Blake diff --git a/block/iscsi.c b/block/iscsi.c index 5c0a9e5..6a1c537 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -658,6 +658,8 @@ static int64_t coroutine_fn iscsi_co_get_block_status(BlockDriverState *bs,      uint64_t lba;      int64_t ret; +    iscsi_co_init_iscsitask(iscsilun, &iTask); +      if (!is_sector_request_lun_aligned(sector_num, nb_sectors, iscsilun)) {          ret = -EINVAL;          goto out; @@ -675,7 +677,6 @@ static int64_t coroutine_fn iscsi_co_get_block_status(BlockDriverState *bs,      lba = sector_qemu2lun(sector_num, iscsilun); -    iscsi_co_init_iscsitask(iscsilun, &iTask);      qemu_mutex_lock(&iscsilun->mutex);  retry:      if (iscsi_get_lba_status_task(iscsilun->iscsi, iscsilun->lun,