From: K. Y. Srinivasan Date: Wed, 18 Mar 2015 19:29:27 +0000 (-0700) Subject: Drivers: hv: vmbus: Fix a bug in rescind processing in vmbus_close_internal() X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=f2eddbc9f1a466329c68f3b75e89cfacd2792365;p=linux-beck.git 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 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c index da53180f5eb4..2c8206d820f2 100644 --- a/drivers/hv/channel.c +++ b/drivers/hv/channel.c @@ -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; }