OSDN Git Service

iscsi: Don't access non-existent scsi_lba_status_descriptor
authorKevin Wolf <kwolf@redhat.com>
Thu, 23 Jan 2020 17:00:54 +0000 (18:00 +0100)
committerKevin Wolf <kwolf@redhat.com>
Mon, 27 Jan 2020 16:19:53 +0000 (17:19 +0100)
In iscsi_co_block_status(), we may have received num_descriptors == 0
from the iscsi server. Therefore, we can't unconditionally access
lbas->descriptors[0]. Add the missing check.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Felipe Franciosi <felipe@nutanix.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Reviewed-by: Peter Lieven <pl@kamp.de>
block/iscsi.c

index cbd5729..c8feaa2 100644 (file)
@@ -753,7 +753,7 @@ retry:
     }
 
     lbas = scsi_datain_unmarshall(iTask.task);
-    if (lbas == NULL) {
+    if (lbas == NULL || lbas->num_descriptors == 0) {
         ret = -EIO;
         goto out_unlock;
     }