From: Sasha Levin Date: Sun, 20 Feb 2022 23:55:48 +0000 (-0500) Subject: Fixes for 5.4 X-Git-Tag: v4.9.303~26^2~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f6e76b7dbb54f28564cdaf7aac7bfbfc0477138f;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.4 Signed-off-by: Sasha Levin --- 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 index 00000000000..0f4a8dcd8a3 --- /dev/null +++ b/queue-5.4/drivers-hv-vmbus-fix-memory-leak-in-vmbus_add_channe.patch @@ -0,0 +1,57 @@ +From fafffa04d5534f65f03129d1315db6c3c44daf80 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +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 + +[ 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 +Reviewed-by: Juan Vazquez +Link: https://lore.kernel.org/r/20220203173008.43480-1-linmq006@gmail.com +Signed-off-by: Wei Liu +Signed-off-by: Sasha Levin +--- + 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 index 00000000000..420797fa089 --- /dev/null +++ b/queue-5.4/kvm-x86-pmu-use-amd64_raw_event_mask-for-perf_type_r.patch @@ -0,0 +1,39 @@ +From d1373e571f9a57df9da553576a541f8eaefbd3e3 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +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 + +[ 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 +Message-Id: <20220203014813.2130559-2-jmattson@google.com> +Reviewed-by: David Dunn +Signed-off-by: Paolo Bonzini +Signed-off-by: Sasha Levin +--- + 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 + diff --git a/queue-5.4/series b/queue-5.4/series index f2c91021d59..827aee80327 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -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