]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 5.4
authorSasha Levin <sashal@kernel.org>
Sun, 20 Feb 2022 23:55:48 +0000 (18:55 -0500)
committerSasha Levin <sashal@kernel.org>
Sun, 20 Feb 2022 23:55:48 +0000 (18:55 -0500)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-5.4/drivers-hv-vmbus-fix-memory-leak-in-vmbus_add_channe.patch [new file with mode: 0644]
queue-5.4/kvm-x86-pmu-use-amd64_raw_event_mask-for-perf_type_r.patch [new file with mode: 0644]
queue-5.4/series

diff --git a/queue-5.4/drivers-hv-vmbus-fix-memory-leak-in-vmbus_add_channe.patch b/queue-5.4/drivers-hv-vmbus-fix-memory-leak-in-vmbus_add_channe.patch
new file mode 100644 (file)
index 0000000..0f4a8dc
--- /dev/null
@@ -0,0 +1,57 @@
+From fafffa04d5534f65f03129d1315db6c3c44daf80 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 4 Feb 2022 01:30:08 +0800
+Subject: Drivers: hv: vmbus: Fix memory leak in vmbus_add_channel_kobj
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Miaoqian Lin <linmq006@gmail.com>
+
+[ Upstream commit 8bc69f86328e87a0ffa79438430cc82f3aa6a194 ]
+
+kobject_init_and_add() takes reference even when it fails.
+According to the doc of kobject_init_and_add():
+
+   If this function returns an error, kobject_put() must be called to
+   properly clean up the memory associated with the object.
+
+Fix memory leak by calling kobject_put().
+
+Fixes: c2e5df616e1a ("vmbus: add per-channel sysfs info")
+Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
+Reviewed-by: Juan Vazquez <juvazq@linux.microsoft.com>
+Link: https://lore.kernel.org/r/20220203173008.43480-1-linmq006@gmail.com
+Signed-off-by: Wei Liu <wei.liu@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/hv/vmbus_drv.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
+index 2d2568dac2a66..6b7ab8f234e87 100644
+--- a/drivers/hv/vmbus_drv.c
++++ b/drivers/hv/vmbus_drv.c
+@@ -1787,8 +1787,10 @@ int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel)
+       kobj->kset = dev->channels_kset;
+       ret = kobject_init_and_add(kobj, &vmbus_chan_ktype, NULL,
+                                  "%u", relid);
+-      if (ret)
++      if (ret) {
++              kobject_put(kobj);
+               return ret;
++      }
+       ret = sysfs_create_group(kobj, &vmbus_chan_group);
+@@ -1797,6 +1799,7 @@ int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel)
+                * The calling functions' error handling paths will cleanup the
+                * empty channel directory.
+                */
++              kobject_put(kobj);
+               dev_err(device, "Unable to set up channel sysfs files\n");
+               return ret;
+       }
+-- 
+2.34.1
+
diff --git a/queue-5.4/kvm-x86-pmu-use-amd64_raw_event_mask-for-perf_type_r.patch b/queue-5.4/kvm-x86-pmu-use-amd64_raw_event_mask-for-perf_type_r.patch
new file mode 100644 (file)
index 0000000..420797f
--- /dev/null
@@ -0,0 +1,39 @@
+From d1373e571f9a57df9da553576a541f8eaefbd3e3 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 2 Feb 2022 17:48:13 -0800
+Subject: KVM: x86/pmu: Use AMD64_RAW_EVENT_MASK for PERF_TYPE_RAW
+
+From: Jim Mattson <jmattson@google.com>
+
+[ Upstream commit 710c476514313c74045c41c0571bb5178fd16e3d ]
+
+AMD's event select is 3 nybbles, with the high nybble in bits 35:32 of
+a PerfEvtSeln MSR. Don't mask off the high nybble when configuring a
+RAW perf event.
+
+Fixes: ca724305a2b0 ("KVM: x86/vPMU: Implement AMD vPMU code for KVM")
+Signed-off-by: Jim Mattson <jmattson@google.com>
+Message-Id: <20220203014813.2130559-2-jmattson@google.com>
+Reviewed-by: David Dunn <daviddunn@google.com>
+Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/x86/kvm/pmu.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
+index 46875bbd04198..e0e3776059af4 100644
+--- a/arch/x86/kvm/pmu.c
++++ b/arch/x86/kvm/pmu.c
+@@ -191,7 +191,7 @@ void reprogram_gp_counter(struct kvm_pmc *pmc, u64 eventsel)
+       }
+       if (type == PERF_TYPE_RAW)
+-              config = eventsel & X86_RAW_EVENT_MASK;
++              config = eventsel & AMD64_RAW_EVENT_MASK;
+       pmc_reprogram_counter(pmc, type, config,
+                             !(eventsel & ARCH_PERFMON_EVENTSEL_USR),
+-- 
+2.34.1
+
index f2c91021d591c639ed111ccd7b09fe08604be398..827aee8032738b45bd0a2b402f31d417a0e6c251 100644 (file)
@@ -56,3 +56,5 @@ nfs-lookup_directory-is-also-ok-with-symlinks.patch
 nfs-do-not-report-writeback-errors-in-nfs_getattr.patch
 mtd-rawnand-qcom-fix-clock-sequencing-in-qcom_nandc_probe.patch
 mtd-rawnand-brcmnand-fixed-incorrect-sub-page-ecc-status.patch
+drivers-hv-vmbus-fix-memory-leak-in-vmbus_add_channe.patch
+kvm-x86-pmu-use-amd64_raw_event_mask-for-perf_type_r.patch