Skip to contentSkip to conversation

Drivers: hv: vmbus: Fix a bug in rescind processing in vmbus_close_internal()

PATCH New K. Y. Srinivasan 1 participant 1 message Mar 10, 2015 Hyper-V/Azure core and drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Drivers: hv: vmbus: Fix a bug in rescind processing in vmbus_close_internal()

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 <[email protected]> for observing this problem. The current code leaks memory when the channel is rescinded.

---
 drivers/hv/channel.c |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)
drivers/hv/channel.c +6 -9
index e58cdb7..fddd3b5 100644
@@ -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;
 }
 
Signature · 1 line
1.7.4.1