diff options
author | K. Y. Srinivasan <kys@microsoft.com> | 2017-03-12 20:00:30 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-03-30 09:41:27 +0200 |
commit | df1fe6c9ad481f6ca1b125a081376744c97d3910 (patch) | |
tree | 22e14c4304deec87aa3b8cb9621beae1228b70a7 /drivers/hv | |
parent | b1f6b0a5a066196e0bf1d504a7afaef4643a13ad (diff) | |
download | linux-stable-df1fe6c9ad481f6ca1b125a081376744c97d3910.tar.gz linux-stable-df1fe6c9ad481f6ca1b125a081376744c97d3910.tar.bz2 linux-stable-df1fe6c9ad481f6ca1b125a081376744c97d3910.zip |
Drivers: hv: vmbus: Don't leak memory when a channel is rescinded
commit 5e030d5ce9d99a899b648413139ff65bab12b038 upstream.
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 <kys@microsoft.com>
Cc: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hv')
-rw-r--r-- | 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 be34547cdb68..1606e7f08f4b 100644 --- a/drivers/hv/channel.c +++ b/drivers/hv/channel.c @@ -506,12 +506,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); |