]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: unisys: uislib: uislib.c: sparse warning of context imbalance
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>
Tue, 9 Sep 2014 10:41:09 +0000 (16:11 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 Sep 2014 21:49:13 +0000 (14:49 -0700)
fixed sparse warning : context imbalance in 'resume_device'
                        unexpected unlock
this patch will generate warning from checkpatch for
lines over 80 character , but since those are user-visible strings
so it was not modified.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Acked-by: Benjamin Romer <benjamin.romer@unisys.com>
Tested-by: Benjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/unisys/uislib/uislib.c

index c4d6cae5aaf0d1cf9d05db7e0d8c5c330379eaed..ae923c3d3841c1c933b553fa4f2e972bdca29512 100644 (file)
@@ -616,6 +616,7 @@ resume_device(CONTROLVM_MESSAGE *msg)
        struct bus_info *bus;
        struct device_info *dev;
        struct guest_msgs cmd;
+       int retval = CONTROLVM_RESP_SUCCESS;
 
        busNo = msg->cmd.deviceChangeState.busNo;
        devNo = msg->cmd.deviceChangeState.devNo;
@@ -627,45 +628,16 @@ resume_device(CONTROLVM_MESSAGE *msg)
                        if (devNo >= bus->deviceCount) {
                                LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: device(%d) >= deviceCount(%d).",
                                     devNo, bus->deviceCount);
-                               read_unlock(&BusListLock);
-                               return CONTROLVM_RESP_ERROR_DEVICE_INVALID;
-                       }
-                       /* make sure this device exists */
-                       dev = bus->device[devNo];
-                       if (!dev) {
-                               LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: device %d does not exist.",
-                                    devNo);
-                               read_unlock(&BusListLock);
-                               return CONTROLVM_RESP_ERROR_ALREADY_DONE;
-                       }
-                       read_unlock(&BusListLock);
-                       /* the msg is bound for virtpci; send
-                        * guest_msgs struct to callback
-                        */
-                       if (!uuid_le_cmp(dev->channelTypeGuid,
-                                       UltraVhbaChannelProtocolGuid)) {
-                               cmd.msgtype = GUEST_RESUME_VHBA;
-                               cmd.resume_vhba.chanptr = dev->chanptr;
-                       } else
-                           if (!uuid_le_cmp(dev->channelTypeGuid,
-                                           UltraVnicChannelProtocolGuid)) {
-                               cmd.msgtype = GUEST_RESUME_VNIC;
-                               cmd.resume_vnic.chanptr = dev->chanptr;
+                               retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID;
                        } else {
-                               LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: unknown channelTypeGuid.\n");
-                               return
-                                   CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN;
-                       }
-
-                       if (!VirtControlChanFunc) {
-                               LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: virtpci callback not registered.");
-                               return
-                                   CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
-                       }
-
-                       if (!VirtControlChanFunc(&cmd)) {
-                               LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: virtpci GUEST_RESUME_[VHBA||VNIC] returned error.");
-                               return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR;
+                               /* make sure this device exists */
+                               dev = bus->device[devNo];
+                               if (!dev) {
+                                       LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: device %d does not exist.",
+                                            devNo);
+                                       retval =
+                                         CONTROLVM_RESP_ERROR_ALREADY_DONE;
+                               }
                        }
                        break;
                }
@@ -674,11 +646,36 @@ resume_device(CONTROLVM_MESSAGE *msg)
        if (!bus) {
                LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: bus %d does not exist",
                     busNo);
-               read_unlock(&BusListLock);
-               return CONTROLVM_RESP_ERROR_BUS_INVALID;
+               retval = CONTROLVM_RESP_ERROR_BUS_INVALID;
        }
-
-       return CONTROLVM_RESP_SUCCESS;
+       read_unlock(&BusListLock);
+       /* the msg is bound for virtpci; send
+        * guest_msgs struct to callback
+        */
+       if (retval == CONTROLVM_RESP_SUCCESS) {
+               if (!uuid_le_cmp(dev->channelTypeGuid,
+                                UltraVhbaChannelProtocolGuid)) {
+                       cmd.msgtype = GUEST_RESUME_VHBA;
+                       cmd.resume_vhba.chanptr = dev->chanptr;
+               } else if (!uuid_le_cmp(dev->channelTypeGuid,
+                                       UltraVnicChannelProtocolGuid)) {
+                       cmd.msgtype = GUEST_RESUME_VNIC;
+                       cmd.resume_vnic.chanptr = dev->chanptr;
+               } else {
+                       LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: unknown channelTypeGuid.\n");
+                       return CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN;
+               }
+               if (!VirtControlChanFunc) {
+                       LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: virtpci callback not registered.");
+                       return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
+               }
+               if (!VirtControlChanFunc(&cmd)) {
+                       LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: virtpci GUEST_RESUME_[VHBA||VNIC] returned error.");
+                       return
+                         CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR;
+               }
+       }
+       return retval;
 }
 
 static int