Skip to content

Commit 7cc80c9

Browse files
vittyvkgregkh
authored andcommitted
Drivers: hv: don't leak memory in vmbus_establish_gpadl()
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>
1 parent 4d63763 commit 7cc80c9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/hv/channel.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
388388
struct vmbus_channel_gpadl_header *gpadlmsg;
389389
struct vmbus_channel_gpadl_body *gpadl_body;
390390
struct vmbus_channel_msginfo *msginfo = NULL;
391-
struct vmbus_channel_msginfo *submsginfo;
391+
struct vmbus_channel_msginfo *submsginfo, *tmp;
392392
struct list_head *curr;
393393
u32 next_gpadl_handle;
394394
unsigned long flags;
@@ -445,6 +445,10 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
445445
spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
446446
list_del(&msginfo->msglistentry);
447447
spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
448+
list_for_each_entry_safe(submsginfo, tmp, &msginfo->submsglist,
449+
msglistentry) {
450+
kfree(submsginfo);
451+
}
448452

449453
kfree(msginfo);
450454
return ret;

0 commit comments

Comments
 (0)