When a channel has been rescinded, the close operation is a noop.
Restructure the code so we deal with the rescind condition after
we properly cleanup the channel. I would like to thank
Dexuan Cui <decui@microsoft.com> for observing this problem.
The current code leaks memory when the channel is rescinded.
The current char-next branch is broken and this patch fixes
the bug.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
                put_cpu();
        }
 
-       /*
-        * If the channel has been rescinded; process device removal.
-        */
-       if (channel->rescind) {
-               hv_process_channel_removal(channel,
-                                          channel->offermsg.child_relid);
-               return 0;
-       }
-
        /* Send a closing message */
 
        msg = &channel->close_msg.msg;
        free_pages((unsigned long)channel->ringbuffer_pages,
                get_order(channel->ringbuffer_pagecount * PAGE_SIZE));
 
+       /*
+        * If the channel has been rescinded; process device removal.
+        */
+       if (channel->rescind)
+               hv_process_channel_removal(channel,
+                                          channel->offermsg.child_relid);
        return ret;
 }