Skip to content

Commit

Permalink
Drivers: hv: vmbus: Don't leak memory when a channel is rescinded
Browse files Browse the repository at this point in the history
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: ccb61f8 ("Drivers: hv: vmbus: Fix a rescind handling bug")

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
K. Y. Srinivasan authored and Greg Kroah-Hartman committed Mar 16, 2017
1 parent 9a54760 commit 5e030d5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions drivers/hv/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5e030d5

Please sign in to comment.