Staging: hv: storvsc: Fix error handling storvsc_host_reset()
authorK. Y. Srinivasan <kys@microsoft.com>
Tue, 8 Nov 2011 17:01:43 +0000 (09:01 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sun, 27 Nov 2011 01:02:07 +0000 (17:02 -0800)
Fix error handling storvsc_host_reset(). I would like to thank
Long Li <longli@microsoft.com> for reporting this.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Reported-by: Long Li <longli@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/hv/storvsc_drv.c

index e16c7a3a402d26a81069a1cecd805a1959aea38c..a1452455e10adc92222bf5b3aaf644876f0edb23 100644 (file)
@@ -1019,7 +1019,7 @@ static int storvsc_host_reset(struct hv_device *device)
 
        stor_device = get_out_stor_device(device);
        if (!stor_device)
-               return -ENODEV;
+               return FAILED;
 
        request = &stor_device->reset_request;
        vstor_packet = &request->vstor_packet;
@@ -1036,13 +1036,11 @@ static int storvsc_host_reset(struct hv_device *device)
                               VM_PKT_DATA_INBAND,
                               VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
        if (ret != 0)
-               goto cleanup;
+               return FAILED;
 
        t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
-       if (t == 0) {
-               ret = -ETIMEDOUT;
-               goto cleanup;
-       }
+       if (t == 0)
+               return TIMEOUT_ERROR;
 
 
        /*
@@ -1050,8 +1048,7 @@ static int storvsc_host_reset(struct hv_device *device)
         * should have been flushed out and return to us
         */
 
-cleanup:
-       return ret;
+       return SUCCESS;
 }
 
 
@@ -1060,16 +1057,11 @@ cleanup:
  */
 static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
 {
-       int ret;
        struct hv_host_device *host_dev =
                (struct hv_host_device *)scmnd->device->host->hostdata;
        struct hv_device *dev = host_dev->dev;
 
-       ret = storvsc_host_reset(dev);
-       if (ret != 0)
-               return ret;
-
-       return ret;
+       return storvsc_host_reset(dev);
 }