]> git.hungrycats.org Git - linux/commitdiff
Drivers: hv: don't leak memory in vmbus_establish_gpadl()
authorVitaly Kuznetsov <vkuznets@redhat.com>
Sat, 4 Jun 2016 00:09:24 +0000 (17:09 -0700)
committerSasha Levin <alexander.levin@verizon.com>
Tue, 13 Jun 2017 13:29:17 +0000 (09:29 -0400)
[ Upstream commit 7cc80c98070ccc7940fc28811c92cca0a681015d ]

In some cases create_gpadl_header() allocates submessages but we never
free them.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
drivers/hv/channel.c

index 54da66dc7d16c033db21664606a0fe7efc576535..990416811277e42d03d12e09586aec105b15ab5a 100644 (file)
@@ -365,7 +365,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;
@@ -427,6 +427,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;
 }