Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933588AbdCMDOw (ORCPT ); Sun, 12 Mar 2017 23:14:52 -0400 Received: from a2nlsmtp01-04.prod.iad2.secureserver.net ([198.71.225.38]:59820 "EHLO a2nlsmtp01-04.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933251AbdCMDOp (ORCPT ); Sun, 12 Mar 2017 23:14:45 -0400 x-originating-ip: 107.180.71.197 From: kys@exchange.microsoft.com To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, vkuznets@redhat.com, jasowang@redhat.com, leann.ogasawara@canonical.com, marcelo.cerri@canonical.com Cc: "K. Y. Srinivasan" Subject: [PATCH 1/1] Drivers: hv: vmbus: Don't leak memory when a channel is rescinded Date: Sun, 12 Mar 2017 20:00:30 -0700 Message-Id: <1489374030-29806-1-git-send-email-kys@exchange.microsoft.com> X-Mailer: git-send-email 1.7.1 Reply-To: kys@microsoft.com X-CMAE-Envelope: MS4wfFKF9KR5bOIBLlfWGq5ri0RGs1qmZy+Z7KPoilf7Fj7xCLU5QMx9Qond4Uqvoa8vAt64mYZcw6dGUbnk2mX8x4/m6j+m+kZoEdUpxLvjyV+YcyqsMHMx Mvx0XuMEm4ssB5G68qgnikDWWdunjWQCvxlcqm028HYnhL0QWXCNQBugPJ5sZS+yn3uCkGT21eJfRwBtmj/Ay97HBtqD/lLMRNRniAzC83JBLRtPfCVFmL/X z8+/2ZsdhZlwkoKPE9OuVXK/rK1eUNA3kLffiItQ+Zz86ZK/2pYhzfKLcPJfIxajejnKDUUiTB/aWtNJ2gsuzmwHIdcZV2M5xqFo73UHGygtgvjQXI3l/cOL iVYgPLiSnJirDxX21dAVpYUfP2ekbsOZECa1l0Gg1Ss/5XigbtsTbd1cHwMtq2Gd8NFDpmiZ7+jabgCN+c7ViD/Dyxv9Qdfw6+UMesK390qaQr5xzuHED6gu zWYfWe0tpSVr+JCuQ5wh58Czg1Aqp7TEnzKj3g== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1204 Lines: 40 From: K. Y. Srinivasan When we close a channel that has been rescinded, we will leak memory since vmbus_teardown_gpadl() returns an error. Fix this so that we can properly cleanup the memory allocated to the ring buffers. Fixes: ccb61f8a99e6 ("Drivers: hv: vmbus: Fix a rescind handling bug") Signed-off-by: K. Y. Srinivasan --- drivers/hv/channel.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c index 54075ac..e9b0fab 100644 --- a/drivers/hv/channel.c +++ b/drivers/hv/channel.c @@ -502,12 +502,15 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle) wait_for_completion(&info->waitevent); - if (channel->rescind) { - ret = -ENODEV; - goto post_msg_err; - } - post_msg_err: + /* + * If the channel has been rescinded; + * we will be awakened by the rescind + * handler; set the error code to zero so we don't leak memory. + */ + if (channel->rescind) + ret = 0; + spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags); list_del(&info->msglistentry); spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags); -- 1.7.1