From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751495AbbCLAlI (ORCPT ); Wed, 11 Mar 2015 20:41:08 -0400 Received: from p3plsmtps2ded04.prod.phx3.secureserver.net ([208.109.80.198]:43139 "EHLO p3plsmtps2ded04.prod.phx3.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752591AbbCLAlD (ORCPT ); Wed, 11 Mar 2015 20:41:03 -0400 x-originating-ip: 72.167.245.219 From: "K. Y. Srinivasan" To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, vkuznets@redhat.com Cc: "K. Y. Srinivasan" Subject: [PATCH 6/6] Drivers: hv: vmbus: Fix a bug in rescind processing in vmbus_close_internal() Date: Wed, 11 Mar 2015 18:56:59 -0700 Message-Id: <1426125419-12571-6-git-send-email-kys@microsoft.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1426125419-12571-1-git-send-email-kys@microsoft.com> References: <1426125345-12530-1-git-send-email-kys@microsoft.com> <1426125419-12571-1-git-send-email-kys@microsoft.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Linux 4.0 RC3 tree is broken and this patch fixes the problem. Signed-off-by: K. Y. Srinivasan --- drivers/hv/channel.c | 15 ++++++--------- 1 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c index da53180..2c8206d 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; } -- 1.7.4.1