Staging: hv: storvsc: Cleanup error handling in storvsc_dev_add()
authorK. Y. Srinivasan <kys@microsoft.com>
Thu, 25 Aug 2011 16:49:02 +0000 (09:49 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 25 Aug 2011 22:29:55 +0000 (15:29 -0700)
Use standard Linux error values and cleanup error handling. I would like
to acknowledge Andre Bartke (andre.bartke@gmail.com) for highlighting this
problem.

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

index 302978611943febbc2ba05f1d6e3d4ff070e2ebc..915aeeed11a167e3473e01e2523f245963be85e3 100644 (file)
@@ -392,10 +392,8 @@ int storvsc_dev_add(struct hv_device *device,
 
        device_info = (struct storvsc_device_info *)additional_info;
        stor_device = alloc_stor_device(device);
-       if (!stor_device) {
-               ret = -1;
-               goto cleanup;
-       }
+       if (!stor_device)
+               return -ENOMEM;
 
        /* Save the channel properties to our storvsc channel */
 
@@ -409,11 +407,13 @@ int storvsc_dev_add(struct hv_device *device,
        stor_device->port_number = device_info->port_number;
        /* Send it back up */
        ret = storvsc_connect_to_vsp(device, device_info->ring_buffer_size);
-
+       if (ret) {
+               free_stor_device(stor_device);
+               return ret;
+       }
        device_info->path_id = stor_device->path_id;
        device_info->target_id = stor_device->target_id;
 
-cleanup:
        return ret;
 }