All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: stable@vger.kernel.org
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>,
	"K . Y . Srinivasan" <kys@microsoft.com>,
	Sumit Semwal <sumit.semwal@linaro.org>,
	Jiri Slaby <jslaby@suse.cz>
Subject: [patch added to 3.12-stable] Drivers: hv: don't leak memory in vmbus_establish_gpadl()
Date: Wed,  3 May 2017 14:22:54 +0200	[thread overview]
Message-ID: <20170503122327.12095-16-jslaby@suse.cz> (raw)
In-Reply-To: <20170503122327.12095-1-jslaby@suse.cz>

From: Vitaly Kuznetsov <vkuznets@redhat.com>

This patch has been added to the 3.12 stable tree. If you have any
objections, please let us know.

===============

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: Jiri Slaby <jslaby@suse.cz>
---
 drivers/hv/channel.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 120237a90a86..8cddbd10dadb 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -403,7 +403,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;
@@ -465,6 +465,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;
 }
-- 
2.12.2

  parent reply	other threads:[~2017-05-03 12:23 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-03 12:22 [patch added to 3.12-stable] rtc: tegra: Implement clock handling Jiri Slaby
2017-05-03 12:22 ` [patch added to 3.12-stable] mm: Tighten x86 /dev/mem with zeroing reads Jiri Slaby
2017-05-03 12:22 ` [patch added to 3.12-stable] virtio-console: avoid DMA from stack Jiri Slaby
2017-05-03 12:22 ` [patch added to 3.12-stable] pegasus: Use heap buffers for all register access Jiri Slaby
2017-05-03 12:22 ` [patch added to 3.12-stable] rtl8150: " Jiri Slaby
2017-05-03 12:22 ` [patch added to 3.12-stable] catc: Combine failure cleanup code in catc_probe() Jiri Slaby
2017-05-03 12:22 ` [patch added to 3.12-stable] catc: Use heap buffer for memory size test Jiri Slaby
2017-05-03 12:22 ` [patch added to 3.12-stable] net: ipv6: check route protocol when deleting routes Jiri Slaby
2017-05-03 12:22 ` [patch added to 3.12-stable] KEYS: Disallow keyrings beginning with '.' to be joined as session keyrings Jiri Slaby
2017-05-03 12:22 ` [patch added to 3.12-stable] KEYS: Change the name of the dead type to ".dead" to prevent user access Jiri Slaby
2017-05-03 12:22 ` [patch added to 3.12-stable] KEYS: fix keyctl_set_reqkey_keyring() to not leak thread keyrings Jiri Slaby
2017-05-03 12:22 ` [patch added to 3.12-stable] tracing: Allocate the snapshot buffer before enabling probe Jiri Slaby
2017-05-03 12:22 ` [patch added to 3.12-stable] ring-buffer: Have ring_buffer_iter_empty() return true when empty Jiri Slaby
2017-05-03 12:22 ` [patch added to 3.12-stable] cifs: Do not send echoes before Negotiate is complete Jiri Slaby
2017-05-03 12:22 ` [patch added to 3.12-stable] CIFS: remove bad_network_name flag Jiri Slaby
2017-05-03 12:22 ` Jiri Slaby [this message]
2017-05-03 12:22 ` [patch added to 3.12-stable] Drivers: hv: get rid of timeout in vmbus_open() Jiri Slaby
2017-05-03 12:22 ` [patch added to 3.12-stable] Input: elantech - add Fujitsu Lifebook E547 to force crc_enabled Jiri Slaby
2017-05-03 12:22 ` [patch added to 3.12-stable] ACPI / power: Avoid maybe-uninitialized warning Jiri Slaby
2017-05-03 12:22 ` [patch added to 3.12-stable] ubi/upd: Always flush after prepared for an update Jiri Slaby
2017-05-03 12:22 ` [patch added to 3.12-stable] x86/mce/AMD: Give a name to MCA bank 3 when accessed with legacy MSRs Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] kvm: arm/arm64: Fix locking for kvm_free_stage2_pgd Jiri Slaby
2017-05-03 12:39   ` Suzuki K Poulose
2017-05-03 13:21     ` Jiri Slaby
2017-05-03 13:31       ` Suzuki K Poulose
2017-05-03 12:23 ` [patch added to 3.12-stable] block: fix del_gendisk() vs blkdev_ioctl crash Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] powerpc: Reject binutils 2.24 when building little endian Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] ping: implement proper locking Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] net/packet: fix overflow in check for tp_frame_nr Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] net/packet: fix overflow in check for tp_reserve Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] netfilter: arp_tables: fix invoking 32bit "iptable -P INPUT ACCEPT" failed in 64bit kernel Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] tty: nozomi: avoid a harmless gcc warning Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] hostap: avoid uninitialized variable use in hfa384x_get_rid Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] gfs2: avoid uninitialized variable warning Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] net: neigh: guard against NULL solicit() method Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] net: phy: handle state correctly in phy_stop_machine Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] l2tp: take reference on sessions being dumped Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] net: ipv4: fix multipath RTM_GETROUTE behavior when iif is given Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] sctp: listen on the sock only when it's state is listening or closed Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] ip6mr: fix notification device destruction Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] ipv6: check raw payload size correctly in ioctl Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] ext4: check if in-inode xattr is corrupted in ext4_expand_extra_isize_ea() Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] md:raid1: fix a dead loop when read from a WriteMostly disk Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] MIPS: Fix crash registers on non-crashing CPUs Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] RDS: Fix the atomicity for congestion map update Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] xen/x86: don't lose event interrupts Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] ALSA: seq: Don't break snd_use_lock_sync() loop by timeout Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] MIPS: KGDB: Use kernel context for sleeping threads Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] p9_client_readdir() fix Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] Input: i8042 - add Clevo P650RS to the i8042 reset list Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] nfsd: check for oversized NFSv2/v3 arguments Jiri Slaby
2017-05-03 12:23 ` [patch added to 3.12-stable] ftrace/x86: Fix triple fault with graph tracing and suspend-to-ram Jiri Slaby

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170503122327.12095-16-jslaby@suse.cz \
    --to=jslaby@suse.cz \
    --cc=kys@microsoft.com \
    --cc=stable@vger.kernel.org \
    --cc=sumit.semwal@linaro.org \
    --cc=vkuznets@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.