aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitaly Kuznetsov <vkuznets@redhat.com>2016-06-03 17:09:24 -0700
committerWilly Tarreau <w@1wt.eu>2017-06-20 14:04:48 +0200
commit0c792ee191ef1297a37d9aadd3a4ffc6696d1429 (patch)
tree8dda1224ba0b68a10d1f6950dbb0b42d3feb90e0
parent3fa16561f160d629f79321616a3e0dab5434e8d3 (diff)
downloadlinux-stable-0c792ee191ef1297a37d9aadd3a4ffc6696d1429.tar.gz
Drivers: hv: don't leak memory in vmbus_establish_gpadl()
commit 7cc80c98070ccc7940fc28811c92cca0a681015d upstream. In some cases create_gpadl_header() allocates submessages but we never free them. [sumits] Note for stable: Upstream commit 4d63763296ab7865a98bc29cc7d77145815ef89f: (Drivers: hv: get rid of redundant messagecount in create_gpadl_header()) changes the list usage to initialize list header in all cases; that patch isn't added to stable, so the current patch is modified a little bit from the upstream commit to check if the list is valid or not. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org> Signed-off-by: Willy Tarreau <w@1wt.eu>
-rw-r--r--drivers/hv/channel.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 05e6a7d13d4e06..90d6885b5825cf 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -391,7 +391,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
struct vmbus_channel_gpadl_header *gpadlmsg;
struct vmbus_channel_gpadl_body *gpadl_body;
struct vmbus_channel_msginfo *msginfo = NULL;
- struct vmbus_channel_msginfo *submsginfo;
+ struct vmbus_channel_msginfo *submsginfo, *tmp;
u32 msgcount;
struct list_head *curr;
u32 next_gpadl_handle;
@@ -453,6 +453,13 @@ cleanup:
list_del(&msginfo->msglistentry);
spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
+ if (msgcount > 1) {
+ list_for_each_entry_safe(submsginfo, tmp, &msginfo->submsglist,
+ msglistentry) {
+ kfree(submsginfo);
+ }
+ }
+
kfree(msginfo);
return ret;
}