]> git.karo-electronics.de Git - linux-beck.git/commitdiff
Drivers: hv: vmbus: Fix a bug in rescind processing in vmbus_close_internal()
authorK. Y. Srinivasan <kys@microsoft.com>
Wed, 18 Mar 2015 19:29:27 +0000 (12:29 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Mar 2015 10:53:54 +0000 (11:53 +0100)
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>
drivers/hv/channel.c

index da53180f5eb43203dca3c15b4dc9fff7b7a8b7fe..2c8206d820f2e8c075fff41421af01391a106b6e 100644 (file)
@@ -501,15 +501,6 @@ static int vmbus_close_internal(struct vmbus_channel *channel)
                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;
@@ -549,6 +540,12 @@ static int vmbus_close_internal(struct vmbus_channel *channel)
        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;
 }