Skip to contentSkip to conversation

Patch "Drivers: hv: don't leak memory in vmbus_establish_gpadl()" has been added to the 4.4-stable tree

PATCH [email protected] 1 participant 1 message Apr 21, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

Drivers: hv: don't leak memory in vmbus_establish_gpadl()

to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
drivers-hv-don-t-leak-memory-in-vmbus_establish_gpadl.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 7cc80c98070ccc7940fc28811c92cca0a681015d Mon Sep 17 00:00:00 2001

From: Vitaly Kuznetsov <[email protected]>
Date: Fri, 3 Jun 2016 17:09:24 -0700
Subject: Drivers: hv: don't leak memory in vmbus_establish_gpadl()

From: Vitaly Kuznetsov <[email protected]>

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.

---
 drivers/hv/channel.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/hv/channel.c +8 -1
@@ -375,7 +375,7 @@ int vmbus_establish_gpadl(struct vmbus_c
 	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;
@@ -437,6 +437,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;
 }

Patches currently in stable-queue which might be from [email protected] are

queue-4.4/drivers-hv-get-rid-of-timeout-in-vmbus_open.patch queue-4.4/drivers-hv-don-t-leak-memory-in-vmbus_establish_gpadl.patch