qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] scsi: Don't check uninitialized local variable


From: Peter Lieven
Subject: Re: [Qemu-devel] [PATCH] scsi: Don't check uninitialized local variable
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

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 <address@hidden>
---
  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:


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,


Peter




--

Mit freundlichen Grüßen

Peter Lieven

...........................................................

  KAMP Netzwerkdienste GmbH
  Vestische Str. 89-91 | 46117 Oberhausen
  Tel: +49 (0) 208.89 402-50 | Fax: +49 (0) 208.89 402-40
  address@hidden | http://www.kamp.de

  Geschäftsführer: Heiner Lante | Michael Lante
  Amtsgericht Duisburg | HRB Nr. 12154
  USt-Id-Nr.: DE 120607556

...........................................................





reply via email to

[Prev in Thread] Current Thread [Next in Thread]