hv: vmbus_open(): reset the channel state on ENOMEM
authorDexuan Cui <decui@microsoft.com>
Fri, 27 Feb 2015 19:26:00 +0000 (11:26 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 2 Mar 2015 03:30:07 +0000 (19:30 -0800)
Without this patch, the state is put to CHANNEL_OPENING_STATE, and when
the driver is loaded next time, vmbus_open() will fail immediately due to
newchannel->state != CHANNEL_OPEN_STATE.

CC: "K. Y. Srinivasan" <kys@microsoft.com>
Signed-off-by: Dexuan Cui <decui@microsoft.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hv/channel.c

index 2978f5ee8d2a0abdeacdc8f7fc2121d35c0260a2..26dcf268b09343aa498e7b04957607a20de53f61 100644 (file)
@@ -89,9 +89,10 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
        out = (void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO,
                get_order(send_ringbuffer_size + recv_ringbuffer_size));
 
-       if (!out)
-               return -ENOMEM;
-
+       if (!out) {
+               err = -ENOMEM;
+               goto error0;
+       }
 
        in = (void *)((unsigned long)out + send_ringbuffer_size);
 
@@ -199,6 +200,7 @@ error0:
        free_pages((unsigned long)out,
                get_order(send_ringbuffer_size + recv_ringbuffer_size));
        kfree(open_info);
+       newchannel->state = CHANNEL_OPEN_STATE;
        return err;
 }
 EXPORT_SYMBOL_GPL(vmbus_open);