power_supply: lp8788-charger: Fix leaked power supply on probe fail
[firefly-linux-kernel-4.4.55.git] / drivers / hv / channel.c
index 0b122f8c7005b75262d88fd0c017e8b3e0faa9aa..92f34de7aee93f78ec582996dd281533059b82f8 100644 (file)
@@ -199,8 +199,10 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
        ret = vmbus_post_msg(open_msg,
                               sizeof(struct vmbus_channel_open_channel));
 
-       if (ret != 0)
+       if (ret != 0) {
+               err = ret;
                goto error1;
+       }
 
        t = wait_for_completion_timeout(&open_info->waitevent, 5*HZ);
        if (t == 0) {
@@ -392,7 +394,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
        u32 next_gpadl_handle;
        unsigned long flags;
        int ret = 0;
-       int t;
 
        next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
        atomic_inc(&vmbus_connection.next_gpadl_handle);
@@ -439,9 +440,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
 
                }
        }
-       t = wait_for_completion_timeout(&msginfo->waitevent, 5*HZ);
-       BUG_ON(t == 0);
-
+       wait_for_completion(&msginfo->waitevent);
 
        /* At this point, we received the gpadl created msg */
        *gpadl_handle = gpadlmsg->gpadl;
@@ -464,7 +463,7 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
        struct vmbus_channel_gpadl_teardown *msg;
        struct vmbus_channel_msginfo *info;
        unsigned long flags;
-       int ret, t;
+       int ret;
 
        info = kmalloc(sizeof(*info) +
                       sizeof(struct vmbus_channel_gpadl_teardown), GFP_KERNEL);
@@ -486,11 +485,12 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
        ret = vmbus_post_msg(msg,
                               sizeof(struct vmbus_channel_gpadl_teardown));
 
-       BUG_ON(ret != 0);
-       t = wait_for_completion_timeout(&info->waitevent, 5*HZ);
-       BUG_ON(t == 0);
+       if (ret)
+               goto post_msg_err;
+
+       wait_for_completion(&info->waitevent);
 
-       /* Received a torndown response */
+post_msg_err:
        spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
        list_del(&info->msglistentry);
        spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);