commit:     221eb616a00bf5d759ee8d7c604ad57cb24e890a
Author:     Mike Pagano <mpagano <AT> gentoo <DOT> org>
AuthorDate: Wed May 20 11:27:34 2020 +0000
Commit:     Mike Pagano <mpagano <AT> gentoo <DOT> org>
CommitDate: Wed May 20 11:27:34 2020 +0000
URL:        https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=221eb616

Linux patch 4.19.124

Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>

 0000_README               |    4 +
 1123_linux-4.19.124.patch | 2125 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 2129 insertions(+)

diff --git a/0000_README b/0000_README
index 18ae34a..4cf06a4 100644
--- a/0000_README
+++ b/0000_README
@@ -531,6 +531,10 @@ Patch:  1122_linux-4.19.123.patch
 From:   https://www.kernel.org
 Desc:   Linux 4.19.123
 
+Patch:  1123_linux-4.19.124.patch
+From:   https://www.kernel.org
+Desc:   Linux 4.19.124
+
 Patch:  1500_XATTR_USER_PREFIX.patch
 From:   https://bugs.gentoo.org/show_bug.cgi?id=470644
 Desc:   Support for namespace user.pax.* on tmpfs.

diff --git a/1123_linux-4.19.124.patch b/1123_linux-4.19.124.patch
new file mode 100644
index 0000000..38dc1e7
--- /dev/null
+++ b/1123_linux-4.19.124.patch
@@ -0,0 +1,2125 @@
+diff --git a/Makefile b/Makefile
+index 68fa15edd662..292c92c8369d 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,7 +1,7 @@
+ # SPDX-License-Identifier: GPL-2.0
+ VERSION = 4
+ PATCHLEVEL = 19
+-SUBLEVEL = 123
++SUBLEVEL = 124
+ EXTRAVERSION =
+ NAME = "People's Front"
+ 
+@@ -657,20 +657,14 @@ KBUILD_CFLAGS    += $(call cc-disable-warning, 
int-in-bool-context)
+ KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
+ 
+ ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
+-KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,)
+-else
+-ifdef CONFIG_PROFILE_ALL_BRANCHES
+-KBUILD_CFLAGS += -O2 $(call cc-disable-warning,maybe-uninitialized,)
++KBUILD_CFLAGS   += -Os
+ else
+ KBUILD_CFLAGS   += -O2
+ endif
+-endif
+-
+-KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \
+-                      $(call cc-disable-warning,maybe-uninitialized,))
+ 
+ # Tell gcc to never replace conditional load with a non-conditional one
+ KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
++KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races)
+ 
+ include scripts/Makefile.kcov
+ include scripts/Makefile.gcc-plugins
+@@ -799,6 +793,17 @@ KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign)
+ # disable stringop warnings in gcc 8+
+ KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
+ 
++# We'll want to enable this eventually, but it's not going away for 5.7 at 
least
++KBUILD_CFLAGS += $(call cc-disable-warning, zero-length-bounds)
++KBUILD_CFLAGS += $(call cc-disable-warning, array-bounds)
++KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
++
++# Another good warning that we'll want to enable eventually
++KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
++
++# Enabled with W=2, disabled by default as noisy
++KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized)
++
+ # disable invalid "can't wrap" optimizations for signed / pointers
+ KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow)
+ 
+diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
+index e97ef16ce68a..0c0781a37c5a 100644
+--- a/arch/arm/boot/dts/dra7.dtsi
++++ b/arch/arm/boot/dts/dra7.dtsi
+@@ -312,6 +312,7 @@
+                       #address-cells = <1>;
+                       ranges = <0x51000000 0x51000000 0x3000
+                                 0x0        0x20000000 0x10000000>;
++                      dma-ranges;
+                       /**
+                        * To enable PCI endpoint mode, disable the pcie1_rc
+                        * node and enable pcie1_ep mode.
+@@ -325,7 +326,6 @@
+                               device_type = "pci";
+                               ranges = <0x81000000 0 0          0x03000 0 
0x00010000
+                                         0x82000000 0 0x20013000 0x13000 0 
0xffed000>;
+-                              dma-ranges = <0x02000000 0x0 0x00000000 
0x00000000 0x1 0x00000000>;
+                               bus-range = <0x00 0xff>;
+                               #interrupt-cells = <1>;
+                               num-lanes = <1>;
+@@ -368,6 +368,7 @@
+                       #address-cells = <1>;
+                       ranges = <0x51800000 0x51800000 0x3000
+                                 0x0        0x30000000 0x10000000>;
++                      dma-ranges;
+                       status = "disabled";
+                       pcie2_rc: pcie@51800000 {
+                               reg = <0x51800000 0x2000>, <0x51802000 0x14c>, 
<0x1000 0x2000>;
+@@ -378,7 +379,6 @@
+                               device_type = "pci";
+                               ranges = <0x81000000 0 0          0x03000 0 
0x00010000
+                                         0x82000000 0 0x30013000 0x13000 0 
0xffed000>;
+-                              dma-ranges = <0x02000000 0x0 0x00000000 
0x00000000 0x1 0x00000000>;
+                               bus-range = <0x00 0xff>;
+                               #interrupt-cells = <1>;
+                               num-lanes = <1>;
+diff --git a/arch/arm/boot/dts/imx27-phytec-phycard-s-rdk.dts 
b/arch/arm/boot/dts/imx27-phytec-phycard-s-rdk.dts
+index bfd4946cf9fe..8b63b6593d3a 100644
+--- a/arch/arm/boot/dts/imx27-phytec-phycard-s-rdk.dts
++++ b/arch/arm/boot/dts/imx27-phytec-phycard-s-rdk.dts
+@@ -81,8 +81,8 @@
+       imx27-phycard-s-rdk {
+               pinctrl_i2c1: i2c1grp {
+                       fsl,pins = <
+-                              MX27_PAD_I2C2_SDA__I2C2_SDA 0x0
+-                              MX27_PAD_I2C2_SCL__I2C2_SCL 0x0
++                              MX27_PAD_I2C_DATA__I2C_DATA 0x0
++                              MX27_PAD_I2C_CLK__I2C_CLK 0x0
+                       >;
+               };
+ 
+diff --git a/arch/arm/boot/dts/r8a73a4.dtsi b/arch/arm/boot/dts/r8a73a4.dtsi
+index dd865f3c2eda..4447f45f0cba 100644
+--- a/arch/arm/boot/dts/r8a73a4.dtsi
++++ b/arch/arm/boot/dts/r8a73a4.dtsi
+@@ -131,7 +131,14 @@
+       cmt1: timer@e6130000 {
+               compatible = "renesas,r8a73a4-cmt1", "renesas,rcar-gen2-cmt1";
+               reg = <0 0xe6130000 0 0x1004>;
+-              interrupts = <GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>;
++              interrupts = <GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>,
++                           <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>,
++                           <GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>,
++                           <GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>,
++                           <GIC_SPI 124 IRQ_TYPE_LEVEL_HIGH>,
++                           <GIC_SPI 125 IRQ_TYPE_LEVEL_HIGH>,
++                           <GIC_SPI 126 IRQ_TYPE_LEVEL_HIGH>,
++                           <GIC_SPI 127 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A73A4_CLK_CMT1>;
+               clock-names = "fck";
+               power-domains = <&pd_c5>;
+diff --git a/arch/arm/boot/dts/r8a7740.dtsi b/arch/arm/boot/dts/r8a7740.dtsi
+index 383cba68dbba..e12ea97eae27 100644
+--- a/arch/arm/boot/dts/r8a7740.dtsi
++++ b/arch/arm/boot/dts/r8a7740.dtsi
+@@ -479,7 +479,7 @@
+               cpg_clocks: cpg_clocks@e6150000 {
+                       compatible = "renesas,r8a7740-cpg-clocks";
+                       reg = <0xe6150000 0x10000>;
+-                      clocks = <&extal1_clk>, <&extalr_clk>;
++                      clocks = <&extal1_clk>, <&extal2_clk>, <&extalr_clk>;
+                       #clock-cells = <1>;
+                       clock-output-names = "system", "pllc0", "pllc1",
+                                            "pllc2", "r",
+diff --git a/arch/arm64/boot/dts/renesas/r8a77980.dtsi 
b/arch/arm64/boot/dts/renesas/r8a77980.dtsi
+index b8c9a56562f2..da5453307d94 100644
+--- a/arch/arm64/boot/dts/renesas/r8a77980.dtsi
++++ b/arch/arm64/boot/dts/renesas/r8a77980.dtsi
+@@ -454,6 +454,7 @@
+               ipmmu_vip0: mmu@e7b00000 {
+                       compatible = "renesas,ipmmu-r8a77980";
+                       reg = <0 0xe7b00000 0 0x1000>;
++                      renesas,ipmmu-main = <&ipmmu_mm 4>;
+                       power-domains = <&sysc R8A77980_PD_ALWAYS_ON>;
+                       #iommu-cells = <1>;
+               };
+@@ -461,6 +462,7 @@
+               ipmmu_vip1: mmu@e7960000 {
+                       compatible = "renesas,ipmmu-r8a77980";
+                       reg = <0 0xe7960000 0 0x1000>;
++                      renesas,ipmmu-main = <&ipmmu_mm 11>;
+                       power-domains = <&sysc R8A77980_PD_ALWAYS_ON>;
+                       #iommu-cells = <1>;
+               };
+diff --git a/arch/arm64/boot/dts/rockchip/rk3328-evb.dts 
b/arch/arm64/boot/dts/rockchip/rk3328-evb.dts
+index 8302d86d35c4..212dd8159da9 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3328-evb.dts
++++ b/arch/arm64/boot/dts/rockchip/rk3328-evb.dts
+@@ -92,7 +92,7 @@
+ &i2c1 {
+       status = "okay";
+ 
+-      rk805: rk805@18 {
++      rk805: pmic@18 {
+               compatible = "rockchip,rk805";
+               reg = <0x18>;
+               interrupt-parent = <&gpio2>;
+diff --git a/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts 
b/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts
+index e9147e35b739..03f2bc7d30d8 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts
++++ b/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts
+@@ -112,7 +112,7 @@
+ &i2c1 {
+       status = "okay";
+ 
+-      rk805: rk805@18 {
++      rk805: pmic@18 {
+               compatible = "rockchip,rk805";
+               reg = <0x18>;
+               interrupt-parent = <&gpio2>;
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi 
b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
+index cea44a7c7cf9..451f00a631c4 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
++++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
+@@ -376,7 +376,7 @@
+               reset-names = "usb3-otg";
+               status = "disabled";
+ 
+-              usbdrd_dwc3_0: dwc3 {
++              usbdrd_dwc3_0: usb@fe800000 {
+                       compatible = "snps,dwc3";
+                       reg = <0x0 0xfe800000 0x0 0x100000>;
+                       interrupts = <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH 0>;
+@@ -409,7 +409,7 @@
+               reset-names = "usb3-otg";
+               status = "disabled";
+ 
+-              usbdrd_dwc3_1: dwc3 {
++              usbdrd_dwc3_1: usb@fe900000 {
+                       compatible = "snps,dwc3";
+                       reg = <0x0 0xfe900000 0x0 0x100000>;
+                       interrupts = <GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH 0>;
+diff --git a/arch/arm64/kernel/machine_kexec.c 
b/arch/arm64/kernel/machine_kexec.c
+index 922add8adb74..5e26ef007863 100644
+--- a/arch/arm64/kernel/machine_kexec.c
++++ b/arch/arm64/kernel/machine_kexec.c
+@@ -192,6 +192,7 @@ void machine_kexec(struct kimage *kimage)
+        * the offline CPUs. Therefore, we must use the __* variant here.
+        */
+       __flush_icache_range((uintptr_t)reboot_code_buffer,
++                           (uintptr_t)reboot_code_buffer +
+                            arm64_relocate_new_kernel_size);
+ 
+       /* Flush the kimage list and its buffers. */
+diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
+index 87f71a6cd3ef..1dd134fc0d84 100644
+--- a/arch/riscv/kernel/vdso/Makefile
++++ b/arch/riscv/kernel/vdso/Makefile
+@@ -30,15 +30,15 @@ $(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE
+       $(call if_changed,vdsold)
+ 
+ # We also create a special relocatable object that should mirror the symbol
+-# table and layout of the linked DSO.  With ld -R we can then refer to
+-# these symbols in the kernel code rather than hand-coded addresses.
++# table and layout of the linked DSO. With ld --just-symbols we can then
++# refer to these symbols in the kernel code rather than hand-coded addresses.
+ 
+ SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
+                             $(call cc-ldoption, -Wl$(comma)--hash-style=both)
+ $(obj)/vdso-dummy.o: $(src)/vdso.lds $(obj)/rt_sigreturn.o FORCE
+       $(call if_changed,vdsold)
+ 
+-LDFLAGS_vdso-syms.o := -r -R
++LDFLAGS_vdso-syms.o := -r --just-symbols
+ $(obj)/vdso-syms.o: $(obj)/vdso-dummy.o FORCE
+       $(call if_changed,ld)
+ 
+diff --git a/arch/x86/include/asm/stackprotector.h 
b/arch/x86/include/asm/stackprotector.h
+index 8ec97a62c245..9c556ea2eaa7 100644
+--- a/arch/x86/include/asm/stackprotector.h
++++ b/arch/x86/include/asm/stackprotector.h
+@@ -55,8 +55,13 @@
+ /*
+  * Initialize the stackprotector canary value.
+  *
+- * NOTE: this must only be called from functions that never return,
++ * NOTE: this must only be called from functions that never return
+  * and it must always be inlined.
++ *
++ * In addition, it should be called from a compilation unit for which
++ * stack protector is disabled. Alternatively, the caller should not end
++ * with a function call which gets tail-call optimized as that would
++ * lead to checking a modified canary value.
+  */
+ static __always_inline void boot_init_stack_canary(void)
+ {
+diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
+index 6489067b78a4..8783d065f927 100644
+--- a/arch/x86/kernel/smpboot.c
++++ b/arch/x86/kernel/smpboot.c
+@@ -269,6 +269,14 @@ static void notrace start_secondary(void *unused)
+ 
+       wmb();
+       cpu_startup_entry(CPUHP_AP_ONLINE_IDLE);
++
++      /*
++       * Prevent tail call to cpu_startup_entry() because the stack protector
++       * guard has been changed a couple of function calls up, in
++       * boot_init_stack_canary() and must not be checked before tail calling
++       * another function.
++       */
++      prevent_tail_call_optimization();
+ }
+ 
+ /**
+diff --git a/arch/x86/kernel/unwind_orc.c b/arch/x86/kernel/unwind_orc.c
+index 169b96492b7c..b48e2686440b 100644
+--- a/arch/x86/kernel/unwind_orc.c
++++ b/arch/x86/kernel/unwind_orc.c
+@@ -589,23 +589,23 @@ EXPORT_SYMBOL_GPL(unwind_next_frame);
+ void __unwind_start(struct unwind_state *state, struct task_struct *task,
+                   struct pt_regs *regs, unsigned long *first_frame)
+ {
+-      if (!orc_init)
+-              goto done;
+-
+       memset(state, 0, sizeof(*state));
+       state->task = task;
+ 
++      if (!orc_init)
++              goto err;
++
+       /*
+        * Refuse to unwind the stack of a task while it's executing on another
+        * CPU.  This check is racy, but that's ok: the unwinder has other
+        * checks to prevent it from going off the rails.
+        */
+       if (task_on_another_cpu(task))
+-              goto done;
++              goto err;
+ 
+       if (regs) {
+               if (user_mode(regs))
+-                      goto done;
++                      goto the_end;
+ 
+               state->ip = regs->ip;
+               state->sp = kernel_stack_pointer(regs);
+@@ -638,6 +638,7 @@ void __unwind_start(struct unwind_state *state, struct 
task_struct *task,
+                * generate some kind of backtrace if this happens.
+                */
+               void *next_page = (void *)PAGE_ALIGN((unsigned long)state->sp);
++              state->error = true;
+               if (get_stack_info(next_page, state->task, &state->stack_info,
+                                  &state->stack_mask))
+                       return;
+@@ -663,8 +664,9 @@ void __unwind_start(struct unwind_state *state, struct 
task_struct *task,
+ 
+       return;
+ 
+-done:
++err:
++      state->error = true;
++the_end:
+       state->stack_info.type = STACK_TYPE_UNKNOWN;
+-      return;
+ }
+ EXPORT_SYMBOL_GPL(__unwind_start);
+diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
+index 6bfc9eaf8dee..b0fd24ee08d2 100644
+--- a/arch/x86/kvm/x86.c
++++ b/arch/x86/kvm/x86.c
+@@ -3423,7 +3423,7 @@ static int kvm_vcpu_ioctl_x86_setup_mce(struct kvm_vcpu 
*vcpu,
+       unsigned bank_num = mcg_cap & 0xff, bank;
+ 
+       r = -EINVAL;
+-      if (!bank_num || bank_num >= KVM_MAX_MCE_BANKS)
++      if (!bank_num || bank_num > KVM_MAX_MCE_BANKS)
+               goto out;
+       if (mcg_cap & ~(kvm_mce_cap_supported | 0xff | 0xff0000))
+               goto out;
+diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c
+index e3b18ad49889..41fd4c123165 100644
+--- a/arch/x86/xen/smp_pv.c
++++ b/arch/x86/xen/smp_pv.c
+@@ -89,6 +89,7 @@ asmlinkage __visible void cpu_bringup_and_idle(void)
+ {
+       cpu_bringup();
+       cpu_startup_entry(CPUHP_AP_ONLINE_IDLE);
++      prevent_tail_call_optimization();
+ }
+ 
+ void xen_smp_intr_free_pv(unsigned int cpu)
+diff --git a/crypto/lrw.c b/crypto/lrw.c
+index 5504d1325a56..d55c9ee18817 100644
+--- a/crypto/lrw.c
++++ b/crypto/lrw.c
+@@ -453,7 +453,7 @@ static void exit_tfm(struct crypto_skcipher *tfm)
+       crypto_free_skcipher(ctx->child);
+ }
+ 
+-static void free(struct skcipher_instance *inst)
++static void free_inst(struct skcipher_instance *inst)
+ {
+       crypto_drop_skcipher(skcipher_instance_ctx(inst));
+       kfree(inst);
+@@ -565,7 +565,7 @@ static int create(struct crypto_template *tmpl, struct 
rtattr **tb)
+       inst->alg.encrypt = encrypt;
+       inst->alg.decrypt = decrypt;
+ 
+-      inst->free = free;
++      inst->free = free_inst;
+ 
+       err = skcipher_register_instance(tmpl, inst);
+       if (err)
+diff --git a/crypto/xts.c b/crypto/xts.c
+index ccf55fbb8bc2..5542dd10aedf 100644
+--- a/crypto/xts.c
++++ b/crypto/xts.c
+@@ -393,7 +393,7 @@ static void exit_tfm(struct crypto_skcipher *tfm)
+       crypto_free_cipher(ctx->tweak);
+ }
+ 
+-static void free(struct skcipher_instance *inst)
++static void free_inst(struct skcipher_instance *inst)
+ {
+       crypto_drop_skcipher(skcipher_instance_ctx(inst));
+       kfree(inst);
+@@ -504,7 +504,7 @@ static int create(struct crypto_template *tmpl, struct 
rtattr **tb)
+       inst->alg.encrypt = encrypt;
+       inst->alg.decrypt = decrypt;
+ 
+-      inst->free = free;
++      inst->free = free_inst;
+ 
+       err = skcipher_register_instance(tmpl, inst);
+       if (err)
+diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
+index 9a3c2b14ac37..9be54e5ef96a 100644
+--- a/drivers/block/virtio_blk.c
++++ b/drivers/block/virtio_blk.c
+@@ -31,6 +31,15 @@ struct virtio_blk_vq {
+ } ____cacheline_aligned_in_smp;
+ 
+ struct virtio_blk {
++      /*
++       * This mutex must be held by anything that may run after
++       * virtblk_remove() sets vblk->vdev to NULL.
++       *
++       * blk-mq, virtqueue processing, and sysfs attribute code paths are
++       * shut down before vblk->vdev is set to NULL and therefore do not need
++       * to hold this mutex.
++       */
++      struct mutex vdev_mutex;
+       struct virtio_device *vdev;
+ 
+       /* The disk structure for the kernel. */
+@@ -42,6 +51,13 @@ struct virtio_blk {
+       /* Process context for config space updates */
+       struct work_struct config_work;
+ 
++      /*
++       * Tracks references from block_device_operations open/release and
++       * virtio_driver probe/remove so this object can be freed once no
++       * longer in use.
++       */
++      refcount_t refs;
++
+       /* What host tells us, plus 2 for header & tailer. */
+       unsigned int sg_elems;
+ 
+@@ -320,10 +336,55 @@ out:
+       return err;
+ }
+ 
++static void virtblk_get(struct virtio_blk *vblk)
++{
++      refcount_inc(&vblk->refs);
++}
++
++static void virtblk_put(struct virtio_blk *vblk)
++{
++      if (refcount_dec_and_test(&vblk->refs)) {
++              ida_simple_remove(&vd_index_ida, vblk->index);
++              mutex_destroy(&vblk->vdev_mutex);
++              kfree(vblk);
++      }
++}
++
++static int virtblk_open(struct block_device *bd, fmode_t mode)
++{
++      struct virtio_blk *vblk = bd->bd_disk->private_data;
++      int ret = 0;
++
++      mutex_lock(&vblk->vdev_mutex);
++
++      if (vblk->vdev)
++              virtblk_get(vblk);
++      else
++              ret = -ENXIO;
++
++      mutex_unlock(&vblk->vdev_mutex);
++      return ret;
++}
++
++static void virtblk_release(struct gendisk *disk, fmode_t mode)
++{
++      struct virtio_blk *vblk = disk->private_data;
++
++      virtblk_put(vblk);
++}
++
+ /* We provide getgeo only to please some old bootloader/partitioning tools */
+ static int virtblk_getgeo(struct block_device *bd, struct hd_geometry *geo)
+ {
+       struct virtio_blk *vblk = bd->bd_disk->private_data;
++      int ret = 0;
++
++      mutex_lock(&vblk->vdev_mutex);
++
++      if (!vblk->vdev) {
++              ret = -ENXIO;
++              goto out;
++      }
+ 
+       /* see if the host passed in geometry config */
+       if (virtio_has_feature(vblk->vdev, VIRTIO_BLK_F_GEOMETRY)) {
+@@ -339,12 +400,16 @@ static int virtblk_getgeo(struct block_device *bd, 
struct hd_geometry *geo)
+               geo->sectors = 1 << 5;
+               geo->cylinders = get_capacity(bd->bd_disk) >> 11;
+       }
+-      return 0;
++out:
++      mutex_unlock(&vblk->vdev_mutex);
++      return ret;
+ }
+ 
+ static const struct block_device_operations virtblk_fops = {
+       .ioctl  = virtblk_ioctl,
+       .owner  = THIS_MODULE,
++      .open = virtblk_open,
++      .release = virtblk_release,
+       .getgeo = virtblk_getgeo,
+ };
+ 
+@@ -672,6 +737,10 @@ static int virtblk_probe(struct virtio_device *vdev)
+               goto out_free_index;
+       }
+ 
++      /* This reference is dropped in virtblk_remove(). */
++      refcount_set(&vblk->refs, 1);
++      mutex_init(&vblk->vdev_mutex);
++
+       vblk->vdev = vdev;
+       vblk->sg_elems = sg_elems;
+ 
+@@ -824,8 +893,6 @@ out:
+ static void virtblk_remove(struct virtio_device *vdev)
+ {
+       struct virtio_blk *vblk = vdev->priv;
+-      int index = vblk->index;
+-      int refc;
+ 
+       /* Make sure no work handler is accessing the device. */
+       flush_work(&vblk->config_work);
+@@ -835,18 +902,21 @@ static void virtblk_remove(struct virtio_device *vdev)
+ 
+       blk_mq_free_tag_set(&vblk->tag_set);
+ 
++      mutex_lock(&vblk->vdev_mutex);
++
+       /* Stop all the virtqueues. */
+       vdev->config->reset(vdev);
+ 
+-      refc = kref_read(&disk_to_dev(vblk->disk)->kobj.kref);
++      /* Virtqueues are stopped, nothing can use vblk->vdev anymore. */
++      vblk->vdev = NULL;
++
+       put_disk(vblk->disk);
+       vdev->config->del_vqs(vdev);
+       kfree(vblk->vqs);
+-      kfree(vblk);
+ 
+-      /* Only free device id if we don't have any users */
+-      if (refc == 1)
+-              ida_simple_remove(&vd_index_ida, index);
++      mutex_unlock(&vblk->vdev_mutex);
++
++      virtblk_put(vblk);
+ }
+ 
+ #ifdef CONFIG_PM_SLEEP
+diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
+index 71621a171f8a..a102eb1abe4b 100644
+--- a/drivers/clk/clk.c
++++ b/drivers/clk/clk.c
+@@ -3105,6 +3105,9 @@ static int __clk_core_init(struct clk_core *core)
+ out:
+       clk_pm_runtime_put(core);
+ unlock:
++      if (ret)
++              hlist_del_init(&core->child_node);
++
+       clk_prepare_unlock();
+ 
+       if (!ret)
+diff --git a/drivers/clk/rockchip/clk-rk3228.c 
b/drivers/clk/rockchip/clk-rk3228.c
+index 7af48184b022..04f4f3739e3b 100644
+--- a/drivers/clk/rockchip/clk-rk3228.c
++++ b/drivers/clk/rockchip/clk-rk3228.c
+@@ -163,8 +163,6 @@ PNAME(mux_i2s_out_p)               = { "i2s1_pre", 
"xin12m" };
+ PNAME(mux_i2s2_p)             = { "i2s2_src", "i2s2_frac", "xin12m" };
+ PNAME(mux_sclk_spdif_p)               = { "sclk_spdif_src", "spdif_frac", 
"xin12m" };
+ 
+-PNAME(mux_aclk_gpu_pre_p)     = { "cpll_gpu", "gpll_gpu", "hdmiphy_gpu", 
"usb480m_gpu" };
+-
+ PNAME(mux_uart0_p)            = { "uart0_src", "uart0_frac", "xin24m" };
+ PNAME(mux_uart1_p)            = { "uart1_src", "uart1_frac", "xin24m" };
+ PNAME(mux_uart2_p)            = { "uart2_src", "uart2_frac", "xin24m" };
+@@ -475,16 +473,9 @@ static struct rockchip_clk_branch rk3228_clk_branches[] 
__initdata = {
+                       RK2928_CLKSEL_CON(24), 6, 10, DFLAGS,
+                       RK2928_CLKGATE_CON(2), 8, GFLAGS),
+ 
+-      GATE(0, "cpll_gpu", "cpll", 0,
+-                      RK2928_CLKGATE_CON(3), 13, GFLAGS),
+-      GATE(0, "gpll_gpu", "gpll", 0,
+-                      RK2928_CLKGATE_CON(3), 13, GFLAGS),
+-      GATE(0, "hdmiphy_gpu", "hdmiphy", 0,
+-                      RK2928_CLKGATE_CON(3), 13, GFLAGS),
+-      GATE(0, "usb480m_gpu", "usb480m", 0,
++      COMPOSITE(0, "aclk_gpu_pre", mux_pll_src_4plls_p, 0,
++                      RK2928_CLKSEL_CON(34), 5, 2, MFLAGS, 0, 5, DFLAGS,
+                       RK2928_CLKGATE_CON(3), 13, GFLAGS),
+-      COMPOSITE_NOGATE(0, "aclk_gpu_pre", mux_aclk_gpu_pre_p, 0,
+-                      RK2928_CLKSEL_CON(34), 5, 2, MFLAGS, 0, 5, DFLAGS),
+ 
+       COMPOSITE(SCLK_SPI0, "sclk_spi0", mux_pll_src_2plls_p, 0,
+                       RK2928_CLKSEL_CON(25), 8, 1, MFLAGS, 0, 7, DFLAGS,
+@@ -589,8 +580,8 @@ static struct rockchip_clk_branch rk3228_clk_branches[] 
__initdata = {
+       GATE(0, "pclk_peri_noc", "pclk_peri", CLK_IGNORE_UNUSED, 
RK2928_CLKGATE_CON(12), 2, GFLAGS),
+ 
+       /* PD_GPU */
+-      GATE(ACLK_GPU, "aclk_gpu", "aclk_gpu_pre", 0, RK2928_CLKGATE_CON(13), 
14, GFLAGS),
+-      GATE(0, "aclk_gpu_noc", "aclk_gpu_pre", 0, RK2928_CLKGATE_CON(13), 15, 
GFLAGS),
++      GATE(ACLK_GPU, "aclk_gpu", "aclk_gpu_pre", 0, RK2928_CLKGATE_CON(7), 
14, GFLAGS),
++      GATE(0, "aclk_gpu_noc", "aclk_gpu_pre", 0, RK2928_CLKGATE_CON(7), 15, 
GFLAGS),
+ 
+       /* PD_BUS */
+       GATE(0, "sclk_initmem_mbist", "aclk_cpu", 0, RK2928_CLKGATE_CON(8), 1, 
GFLAGS),
+diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
+index 29f25d5d65e0..e7b3d4ed8eff 100644
+--- a/drivers/cpufreq/intel_pstate.c
++++ b/drivers/cpufreq/intel_pstate.c
+@@ -957,7 +957,7 @@ static ssize_t store_no_turbo(struct kobject *a, struct 
kobj_attribute *b,
+ 
+       update_turbo_state();
+       if (global.turbo_disabled) {
+-              pr_warn("Turbo disabled by BIOS or unavailable on processor\n");
++              pr_notice_once("Turbo disabled by BIOS or unavailable on 
processor\n");
+               mutex_unlock(&intel_pstate_limits_lock);
+               mutex_unlock(&intel_pstate_driver_lock);
+               return -EPERM;
+diff --git a/drivers/dma/mmp_tdma.c b/drivers/dma/mmp_tdma.c
+index 13c68b6434ce..15b4a44e6006 100644
+--- a/drivers/dma/mmp_tdma.c
++++ b/drivers/dma/mmp_tdma.c
+@@ -362,6 +362,8 @@ static void mmp_tdma_free_descriptor(struct mmp_tdma_chan 
*tdmac)
+               gen_pool_free(gpool, (unsigned long)tdmac->desc_arr,
+                               size);
+       tdmac->desc_arr = NULL;
++      if (tdmac->status == DMA_ERROR)
++              tdmac->status = DMA_COMPLETE;
+ 
+       return;
+ }
+diff --git a/drivers/dma/pch_dma.c b/drivers/dma/pch_dma.c
+index afd8f27bda96..6e91584c3677 100644
+--- a/drivers/dma/pch_dma.c
++++ b/drivers/dma/pch_dma.c
+@@ -873,6 +873,7 @@ static int pch_dma_probe(struct pci_dev *pdev,
+       }
+ 
+       pci_set_master(pdev);
++      pd->dma.dev = &pdev->dev;
+ 
+       err = request_irq(pdev->irq, pd_irq, IRQF_SHARED, DRV_NAME, pd);
+       if (err) {
+@@ -888,7 +889,6 @@ static int pch_dma_probe(struct pci_dev *pdev,
+               goto err_free_irq;
+       }
+ 
+-      pd->dma.dev = &pdev->dev;
+ 
+       INIT_LIST_HEAD(&pd->dma.channels);
+ 
+diff --git a/drivers/gpu/drm/qxl/qxl_image.c b/drivers/gpu/drm/qxl/qxl_image.c
+index 7fbcc35e8ad3..c89c10055641 100644
+--- a/drivers/gpu/drm/qxl/qxl_image.c
++++ b/drivers/gpu/drm/qxl/qxl_image.c
+@@ -210,7 +210,8 @@ qxl_image_init_helper(struct qxl_device *qdev,
+               break;
+       default:
+               DRM_ERROR("unsupported image bit depth\n");
+-              return -EINVAL; /* TODO: cleanup */
++              qxl_bo_kunmap_atomic_page(qdev, image_bo, ptr);
++              return -EINVAL;
+       }
+       image->u.bitmap.flags = QXL_BITMAP_TOP_DOWN;
+       image->u.bitmap.x = width;
+diff --git a/drivers/hwmon/da9052-hwmon.c b/drivers/hwmon/da9052-hwmon.c
+index a973eb6a2890..9e44d2385e6f 100644
+--- a/drivers/hwmon/da9052-hwmon.c
++++ b/drivers/hwmon/da9052-hwmon.c
+@@ -250,9 +250,9 @@ static ssize_t da9052_read_tsi(struct device *dev,
+       int channel = to_sensor_dev_attr(devattr)->index;
+       int ret;
+ 
+-      mutex_lock(&hwmon->hwmon_lock);
++      mutex_lock(&hwmon->da9052->auxadc_lock);
+       ret = __da9052_read_tsi(dev, channel);
+-      mutex_unlock(&hwmon->hwmon_lock);
++      mutex_unlock(&hwmon->da9052->auxadc_lock);
+ 
+       if (ret < 0)
+               return ret;
+diff --git a/drivers/infiniband/hw/i40iw/i40iw_hw.c 
b/drivers/infiniband/hw/i40iw/i40iw_hw.c
+index 55a1fbf0e670..ae8b97c30665 100644
+--- a/drivers/infiniband/hw/i40iw/i40iw_hw.c
++++ b/drivers/infiniband/hw/i40iw/i40iw_hw.c
+@@ -534,7 +534,7 @@ void i40iw_manage_arp_cache(struct i40iw_device *iwdev,
+       int arp_index;
+ 
+       arp_index = i40iw_arp_table(iwdev, ip_addr, ipv4, mac_addr, action);
+-      if (arp_index == -1)
++      if (arp_index < 0)
+               return;
+       cqp_request = i40iw_get_cqp_request(&iwdev->cqp, false);
+       if (!cqp_request)
+diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
+index 6dd3cd2c2f80..73bd35d34a25 100644
+--- a/drivers/infiniband/hw/mlx4/qp.c
++++ b/drivers/infiniband/hw/mlx4/qp.c
+@@ -2807,6 +2807,7 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp 
*sqp,
+       int send_size;
+       int header_size;
+       int spc;
++      int err;
+       int i;
+ 
+       if (wr->wr.opcode != IB_WR_SEND)
+@@ -2841,7 +2842,9 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp 
*sqp,
+ 
+       sqp->ud_header.lrh.virtual_lane    = 0;
+       sqp->ud_header.bth.solicited_event = !!(wr->wr.send_flags & 
IB_SEND_SOLICITED);
+-      ib_get_cached_pkey(ib_dev, sqp->qp.port, 0, &pkey);
++      err = ib_get_cached_pkey(ib_dev, sqp->qp.port, 0, &pkey);
++      if (err)
++              return err;
+       sqp->ud_header.bth.pkey = cpu_to_be16(pkey);
+       if (sqp->qp.mlx4_ib_qp_type == MLX4_IB_QPT_TUN_SMI_OWNER)
+               sqp->ud_header.bth.destination_qpn = 
cpu_to_be32(wr->remote_qpn);
+@@ -3128,9 +3131,14 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, 
const struct ib_ud_wr *wr,
+       }
+       sqp->ud_header.bth.solicited_event = !!(wr->wr.send_flags & 
IB_SEND_SOLICITED);
+       if (!sqp->qp.ibqp.qp_num)
+-              ib_get_cached_pkey(ib_dev, sqp->qp.port, sqp->pkey_index, 
&pkey);
++              err = ib_get_cached_pkey(ib_dev, sqp->qp.port, sqp->pkey_index,
++                                       &pkey);
+       else
+-              ib_get_cached_pkey(ib_dev, sqp->qp.port, wr->pkey_index, &pkey);
++              err = ib_get_cached_pkey(ib_dev, sqp->qp.port, wr->pkey_index,
++                                       &pkey);
++      if (err)
++              return err;
++
+       sqp->ud_header.bth.pkey = cpu_to_be16(pkey);
+       sqp->ud_header.bth.destination_qpn = cpu_to_be32(wr->remote_qpn);
+       sqp->ud_header.bth.psn = cpu_to_be32((sqp->send_psn++) & ((1 << 24) - 
1));
+diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
+index 60eac66dc9f0..23bcdbba0cab 100644
+--- a/drivers/mmc/core/block.c
++++ b/drivers/mmc/core/block.c
+@@ -1424,6 +1424,7 @@ static void mmc_blk_cqe_complete_rq(struct mmc_queue 
*mq, struct request *req)
+       struct mmc_request *mrq = &mqrq->brq.mrq;
+       struct request_queue *q = req->q;
+       struct mmc_host *host = mq->card->host;
++      enum mmc_issue_type issue_type = mmc_issue_type(mq, req);
+       unsigned long flags;
+       bool put_card;
+       int err;
+@@ -1453,7 +1454,7 @@ static void mmc_blk_cqe_complete_rq(struct mmc_queue 
*mq, struct request *req)
+ 
+       spin_lock_irqsave(q->queue_lock, flags);
+ 
+-      mq->in_flight[mmc_issue_type(mq, req)] -= 1;
++      mq->in_flight[issue_type] -= 1;
+ 
+       put_card = (mmc_tot_in_flight(mq) == 0);
+ 
+diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c
+index becc6594a8a4..03f3d9c80fba 100644
+--- a/drivers/mmc/core/queue.c
++++ b/drivers/mmc/core/queue.c
+@@ -111,8 +111,7 @@ static enum blk_eh_timer_return mmc_cqe_timed_out(struct 
request *req)
+                               __mmc_cqe_recovery_notifier(mq);
+                       return BLK_EH_RESET_TIMER;
+               }
+-              /* No timeout (XXX: huh? comment doesn't make much sense) */
+-              blk_mq_complete_request(req);
++              /* The request has gone already */
+               return BLK_EH_DONE;
+       default:
+               /* Timeout is handled by mmc core */
+diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
+index 57c1ec322e42..145143b6a0e6 100644
+--- a/drivers/mmc/host/sdhci-acpi.c
++++ b/drivers/mmc/host/sdhci-acpi.c
+@@ -552,10 +552,12 @@ static int sdhci_acpi_emmc_amd_probe_slot(struct 
platform_device *pdev,
+ }
+ 
+ static const struct sdhci_acpi_slot sdhci_acpi_slot_amd_emmc = {
+-      .chip   = &sdhci_acpi_chip_amd,
+-      .caps   = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
+-      .quirks = SDHCI_QUIRK_32BIT_DMA_ADDR | SDHCI_QUIRK_32BIT_DMA_SIZE |
+-                      SDHCI_QUIRK_32BIT_ADMA_SIZE,
++      .chip           = &sdhci_acpi_chip_amd,
++      .caps           = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
++      .quirks         = SDHCI_QUIRK_32BIT_DMA_ADDR |
++                        SDHCI_QUIRK_32BIT_DMA_SIZE |
++                        SDHCI_QUIRK_32BIT_ADMA_SIZE,
++      .quirks2        = SDHCI_QUIRK2_BROKEN_64_BIT_DMA,
+       .probe_slot     = sdhci_acpi_emmc_amd_probe_slot,
+ };
+ 
+diff --git a/drivers/net/dsa/dsa_loop.c b/drivers/net/dsa/dsa_loop.c
+index 816f34d64736..990de7c54b46 100644
+--- a/drivers/net/dsa/dsa_loop.c
++++ b/drivers/net/dsa/dsa_loop.c
+@@ -360,6 +360,7 @@ static void __exit dsa_loop_exit(void)
+ }
+ module_exit(dsa_loop_exit);
+ 
++MODULE_SOFTDEP("pre: dsa_loop_bdinfo");
+ MODULE_LICENSE("GPL");
+ MODULE_AUTHOR("Florian Fainelli");
+ MODULE_DESCRIPTION("DSA loopback driver");
+diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_mgmt.c 
b/drivers/net/ethernet/huawei/hinic/hinic_hw_mgmt.c
+index 9fcf2e5e0003..0e40d647093c 100644
+--- a/drivers/net/ethernet/huawei/hinic/hinic_hw_mgmt.c
++++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_mgmt.c
+@@ -54,6 +54,8 @@
+ 
+ #define MGMT_MSG_TIMEOUT                5000
+ 
++#define SET_FUNC_PORT_MGMT_TIMEOUT    25000
++
+ #define mgmt_to_pfhwdev(pf_mgmt)        \
+               container_of(pf_mgmt, struct hinic_pfhwdev, pf_to_mgmt)
+ 
+@@ -247,12 +249,13 @@ static int msg_to_mgmt_sync(struct hinic_pf_to_mgmt 
*pf_to_mgmt,
+                           u8 *buf_in, u16 in_size,
+                           u8 *buf_out, u16 *out_size,
+                           enum mgmt_direction_type direction,
+-                          u16 resp_msg_id)
++                          u16 resp_msg_id, u32 timeout)
+ {
+       struct hinic_hwif *hwif = pf_to_mgmt->hwif;
+       struct pci_dev *pdev = hwif->pdev;
+       struct hinic_recv_msg *recv_msg;
+       struct completion *recv_done;
++      unsigned long timeo;
+       u16 msg_id;
+       int err;
+ 
+@@ -276,8 +279,9 @@ static int msg_to_mgmt_sync(struct hinic_pf_to_mgmt 
*pf_to_mgmt,
+               goto unlock_sync_msg;
+       }
+ 
+-      if (!wait_for_completion_timeout(recv_done,
+-                                       msecs_to_jiffies(MGMT_MSG_TIMEOUT))) {
++      timeo = msecs_to_jiffies(timeout ? timeout : MGMT_MSG_TIMEOUT);
++
++      if (!wait_for_completion_timeout(recv_done, timeo)) {
+               dev_err(&pdev->dev, "MGMT timeout, MSG id = %d\n", msg_id);
+               err = -ETIMEDOUT;
+               goto unlock_sync_msg;
+@@ -351,6 +355,7 @@ int hinic_msg_to_mgmt(struct hinic_pf_to_mgmt *pf_to_mgmt,
+ {
+       struct hinic_hwif *hwif = pf_to_mgmt->hwif;
+       struct pci_dev *pdev = hwif->pdev;
++      u32 timeout = 0;
+ 
+       if (sync != HINIC_MGMT_MSG_SYNC) {
+               dev_err(&pdev->dev, "Invalid MGMT msg type\n");
+@@ -362,9 +367,12 @@ int hinic_msg_to_mgmt(struct hinic_pf_to_mgmt *pf_to_mgmt,
+               return -EINVAL;
+       }
+ 
++      if (cmd == HINIC_PORT_CMD_SET_FUNC_STATE)
++              timeout = SET_FUNC_PORT_MGMT_TIMEOUT;
++
+       return msg_to_mgmt_sync(pf_to_mgmt, mod, cmd, buf_in, in_size,
+                               buf_out, out_size, MGMT_DIRECT_SEND,
+-                              MSG_NOT_RESP);
++                              MSG_NOT_RESP, timeout);
+ }
+ 
+ /**
+diff --git a/drivers/net/ethernet/huawei/hinic/hinic_main.c 
b/drivers/net/ethernet/huawei/hinic/hinic_main.c
+index 2352046971a4..23de5fa3d885 100644
+--- a/drivers/net/ethernet/huawei/hinic/hinic_main.c
++++ b/drivers/net/ethernet/huawei/hinic/hinic_main.c
+@@ -475,7 +475,6 @@ static int hinic_close(struct net_device *netdev)
+ {
+       struct hinic_dev *nic_dev = netdev_priv(netdev);
+       unsigned int flags;
+-      int err;
+ 
+       down(&nic_dev->mgmt_lock);
+ 
+@@ -489,20 +488,9 @@ static int hinic_close(struct net_device *netdev)
+ 
+       up(&nic_dev->mgmt_lock);
+ 
+-      err = hinic_port_set_func_state(nic_dev, HINIC_FUNC_PORT_DISABLE);
+-      if (err) {
+-              netif_err(nic_dev, drv, netdev,
+-                        "Failed to set func port state\n");
+-              nic_dev->flags |= (flags & HINIC_INTF_UP);
+-              return err;
+-      }
++      hinic_port_set_state(nic_dev, HINIC_PORT_DISABLE);
+ 
+-      err = hinic_port_set_state(nic_dev, HINIC_PORT_DISABLE);
+-      if (err) {
+-              netif_err(nic_dev, drv, netdev, "Failed to set port state\n");
+-              nic_dev->flags |= (flags & HINIC_INTF_UP);
+-              return err;
+-      }
++      hinic_port_set_func_state(nic_dev, HINIC_FUNC_PORT_DISABLE);
+ 
+       free_rxqs(nic_dev);
+       free_txqs(nic_dev);
+diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
+index b34055ac476f..4db3431b79ac 100644
+--- a/drivers/net/ethernet/moxa/moxart_ether.c
++++ b/drivers/net/ethernet/moxa/moxart_ether.c
+@@ -561,7 +561,7 @@ static int moxart_remove(struct platform_device *pdev)
+       struct net_device *ndev = platform_get_drvdata(pdev);
+ 
+       unregister_netdev(ndev);
+-      free_irq(ndev->irq, ndev);
++      devm_free_irq(&pdev->dev, ndev->irq, ndev);
+       moxart_mac_free_memory(ndev);
+       free_netdev(ndev);
+ 
+diff --git a/drivers/net/ethernet/natsemi/jazzsonic.c 
b/drivers/net/ethernet/natsemi/jazzsonic.c
+index 51fa82b429a3..40970352d208 100644
+--- a/drivers/net/ethernet/natsemi/jazzsonic.c
++++ b/drivers/net/ethernet/natsemi/jazzsonic.c
+@@ -235,11 +235,13 @@ static int jazz_sonic_probe(struct platform_device *pdev)
+ 
+       err = register_netdev(dev);
+       if (err)
+-              goto out1;
++              goto undo_probe1;
+ 
+       return 0;
+ 
+-out1:
++undo_probe1:
++      dma_free_coherent(lp->device, SIZEOF_SONIC_DESC * 
SONIC_BUS_SCALE(lp->dma_bitmode),
++                        lp->descriptors, lp->descriptors_laddr);
+       release_mem_region(dev->base_addr, SONIC_MEM_SIZE);
+ out:
+       free_netdev(dev);
+diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
+index 1ee25877c4d1..cc454b8c032c 100644
+--- a/drivers/net/phy/phy.c
++++ b/drivers/net/phy/phy.c
+@@ -1302,9 +1302,11 @@ int phy_ethtool_set_eee(struct phy_device *phydev, 
struct ethtool_eee *data)
+               /* Restart autonegotiation so the new modes get sent to the
+                * link partner.
+                */
+-              ret = phy_restart_aneg(phydev);
+-              if (ret < 0)
+-                      return ret;
++              if (phydev->autoneg == AUTONEG_ENABLE) {
++                      ret = phy_restart_aneg(phydev);
++                      if (ret < 0)
++                              return ret;
++              }
+       }
+ 
+       return 0;
+diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c
+index c04f3dc17d76..b8342162f3a0 100644
+--- a/drivers/net/ppp/pppoe.c
++++ b/drivers/net/ppp/pppoe.c
+@@ -497,6 +497,9 @@ static int pppoe_disc_rcv(struct sk_buff *skb, struct 
net_device *dev,
+       if (!skb)
+               goto out;
+ 
++      if (skb->pkt_type != PACKET_HOST)
++              goto abort;
++
+       if (!pskb_may_pull(skb, sizeof(struct pppoe_hdr)))
+               goto abort;
+ 
+diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
+index c88ee376a2eb..b21223be93c8 100644
+--- a/drivers/net/virtio_net.c
++++ b/drivers/net/virtio_net.c
+@@ -1242,9 +1242,11 @@ static bool try_fill_recv(struct virtnet_info *vi, 
struct receive_queue *rq,
+                       break;
+       } while (rq->vq->num_free);
+       if (virtqueue_kick_prepare(rq->vq) && virtqueue_notify(rq->vq)) {
+-              u64_stats_update_begin(&rq->stats.syncp);
++              unsigned long flags;
++
++              flags = u64_stats_update_begin_irqsave(&rq->stats.syncp);
+               rq->stats.kicks++;
+-              u64_stats_update_end(&rq->stats.syncp);
++              u64_stats_update_end_irqrestore(&rq->stats.syncp, flags);
+       }
+ 
+       return !oom;
+diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c 
b/drivers/pinctrl/intel/pinctrl-baytrail.c
+index a760d8bda0af..acb02a7aa949 100644
+--- a/drivers/pinctrl/intel/pinctrl-baytrail.c
++++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
+@@ -1495,6 +1495,7 @@ static const struct gpio_chip byt_gpio_chip = {
+       .direction_output       = byt_gpio_direction_output,
+       .get                    = byt_gpio_get,
+       .set                    = byt_gpio_set,
++      .set_config             = gpiochip_generic_config,
+       .dbg_show               = byt_gpio_dbg_show,
+ };
+ 
+diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c 
b/drivers/pinctrl/intel/pinctrl-cherryview.c
+index f16baf9b8696..25932d2a7154 100644
+--- a/drivers/pinctrl/intel/pinctrl-cherryview.c
++++ b/drivers/pinctrl/intel/pinctrl-cherryview.c
+@@ -1485,11 +1485,15 @@ static void chv_gpio_irq_handler(struct irq_desc *desc)
+       struct chv_pinctrl *pctrl = gpiochip_get_data(gc);
+       struct irq_chip *chip = irq_desc_get_chip(desc);
+       unsigned long pending;
++      unsigned long flags;
+       u32 intr_line;
+ 
+       chained_irq_enter(chip, desc);
+ 
++      raw_spin_lock_irqsave(&chv_lock, flags);
+       pending = readl(pctrl->regs + CHV_INTSTAT);
++      raw_spin_unlock_irqrestore(&chv_lock, flags);
++
+       for_each_set_bit(intr_line, &pending, pctrl->community->nirqs) {
+               unsigned irq, offset;
+ 
+diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
+index ac8535d2b41a..6bb45ae19d58 100644
+--- a/drivers/scsi/sg.c
++++ b/drivers/scsi/sg.c
+@@ -694,8 +694,10 @@ sg_write(struct file *filp, const char __user *buf, 
size_t count, loff_t * ppos)
+       hp->flags = input_size; /* structure abuse ... */
+       hp->pack_id = old_hdr.pack_id;
+       hp->usr_ptr = NULL;
+-      if (__copy_from_user(cmnd, buf, cmd_size))
++      if (__copy_from_user(cmnd, buf, cmd_size)) {
++              sg_remove_request(sfp, srp);
+               return -EFAULT;
++      }
+       /*
+        * SG_DXFER_TO_FROM_DEV is functionally equivalent to SG_DXFER_FROM_DEV,
+        * but is is possible that the app intended SG_DXFER_TO_DEV, because 
there
+diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
+index fffe544d9e9f..fa28f23a4a33 100644
+--- a/drivers/usb/core/hub.c
++++ b/drivers/usb/core/hub.c
+@@ -37,6 +37,7 @@
+ 
+ #define USB_VENDOR_GENESYS_LOGIC              0x05e3
+ #define USB_VENDOR_SMSC                               0x0424
++#define USB_PRODUCT_USB5534B                  0x5534
+ #define HUB_QUIRK_CHECK_PORT_AUTOSUSPEND      0x01
+ #define HUB_QUIRK_DISABLE_AUTOSUSPEND         0x02
+ 
+@@ -5434,8 +5435,11 @@ out_hdev_lock:
+ }
+ 
+ static const struct usb_device_id hub_id_table[] = {
+-    { .match_flags = USB_DEVICE_ID_MATCH_VENDOR | 
USB_DEVICE_ID_MATCH_INT_CLASS,
++    { .match_flags = USB_DEVICE_ID_MATCH_VENDOR
++                   | USB_DEVICE_ID_MATCH_PRODUCT
++                   | USB_DEVICE_ID_MATCH_INT_CLASS,
+       .idVendor = USB_VENDOR_SMSC,
++      .idProduct = USB_PRODUCT_USB5534B,
+       .bInterfaceClass = USB_CLASS_HUB,
+       .driver_info = HUB_QUIRK_DISABLE_AUTOSUSPEND},
+     { .match_flags = USB_DEVICE_ID_MATCH_VENDOR
+diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
+index 99f6a5aa0109..8e66954dfcd4 100644
+--- a/drivers/usb/dwc3/gadget.c
++++ b/drivers/usb/dwc3/gadget.c
+@@ -2279,9 +2279,6 @@ static int dwc3_gadget_ep_reclaim_trb_sg(struct dwc3_ep 
*dep,
+       for_each_sg(sg, s, pending, i) {
+               trb = &dep->trb_pool[dep->trb_dequeue];
+ 
+-              if (trb->ctrl & DWC3_TRB_CTRL_HWO)
+-                      break;
+-
+               req->sg = sg_next(s);
+               req->num_pending_sgs--;
+ 
+diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
+index ab9ac48a751a..a7709d126b29 100644
+--- a/drivers/usb/gadget/configfs.c
++++ b/drivers/usb/gadget/configfs.c
+@@ -260,6 +260,9 @@ static ssize_t gadget_dev_desc_UDC_store(struct 
config_item *item,
+       char *name;
+       int ret;
+ 
++      if (strlen(page) < len)
++              return -EOVERFLOW;
++
+       name = kstrdup(page, GFP_KERNEL);
+       if (!name)
+               return -ENOMEM;
+diff --git a/drivers/usb/gadget/legacy/audio.c 
b/drivers/usb/gadget/legacy/audio.c
+index dd81fd538cb8..a748ed0842e8 100644
+--- a/drivers/usb/gadget/legacy/audio.c
++++ b/drivers/usb/gadget/legacy/audio.c
+@@ -300,8 +300,10 @@ static int audio_bind(struct usb_composite_dev *cdev)
+               struct usb_descriptor_header *usb_desc;
+ 
+               usb_desc = usb_otg_descriptor_alloc(cdev->gadget);
+-              if (!usb_desc)
++              if (!usb_desc) {
++                      status = -ENOMEM;
+                       goto fail;
++              }
+               usb_otg_descriptor_init(cdev->gadget, usb_desc);
+               otg_desc[0] = usb_desc;
+               otg_desc[1] = NULL;
+diff --git a/drivers/usb/gadget/legacy/cdc2.c 
b/drivers/usb/gadget/legacy/cdc2.c
+index 8d7a556ece30..563363aba48f 100644
+--- a/drivers/usb/gadget/legacy/cdc2.c
++++ b/drivers/usb/gadget/legacy/cdc2.c
+@@ -179,8 +179,10 @@ static int cdc_bind(struct usb_composite_dev *cdev)
+               struct usb_descriptor_header *usb_desc;
+ 
+               usb_desc = usb_otg_descriptor_alloc(gadget);
+-              if (!usb_desc)
++              if (!usb_desc) {
++                      status = -ENOMEM;
+                       goto fail1;
++              }
+               usb_otg_descriptor_init(gadget, usb_desc);
+               otg_desc[0] = usb_desc;
+               otg_desc[1] = NULL;
+diff --git a/drivers/usb/gadget/legacy/ncm.c b/drivers/usb/gadget/legacy/ncm.c
+index c61e71ba7045..0f1b45e3abd1 100644
+--- a/drivers/usb/gadget/legacy/ncm.c
++++ b/drivers/usb/gadget/legacy/ncm.c
+@@ -156,8 +156,10 @@ static int gncm_bind(struct usb_composite_dev *cdev)
+               struct usb_descriptor_header *usb_desc;
+ 
+               usb_desc = usb_otg_descriptor_alloc(gadget);
+-              if (!usb_desc)
++              if (!usb_desc) {
++                      status = -ENOMEM;
+                       goto fail;
++              }
+               usb_otg_descriptor_init(gadget, usb_desc);
+               otg_desc[0] = usb_desc;
+               otg_desc[1] = NULL;
+diff --git a/drivers/usb/gadget/udc/net2272.c 
b/drivers/usb/gadget/udc/net2272.c
+index c2011cd7df8c..077fa9304618 100644
+--- a/drivers/usb/gadget/udc/net2272.c
++++ b/drivers/usb/gadget/udc/net2272.c
+@@ -2653,6 +2653,8 @@ net2272_plat_probe(struct platform_device *pdev)
+  err_req:
+       release_mem_region(base, len);
+  err:
++      kfree(dev);
++
+       return ret;
+ }
+ 
+diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
+index 9602241e4371..adc437ca83b8 100644
+--- a/drivers/usb/host/xhci-plat.c
++++ b/drivers/usb/host/xhci-plat.c
+@@ -361,6 +361,7 @@ static int xhci_plat_remove(struct platform_device *dev)
+       struct clk *reg_clk = xhci->reg_clk;
+       struct usb_hcd *shared_hcd = xhci->shared_hcd;
+ 
++      pm_runtime_get_sync(&dev->dev);
+       xhci->xhc_state |= XHCI_STATE_REMOVING;
+ 
+       usb_remove_hcd(shared_hcd);
+@@ -374,8 +375,9 @@ static int xhci_plat_remove(struct platform_device *dev)
+       clk_disable_unprepare(reg_clk);
+       usb_put_hcd(hcd);
+ 
+-      pm_runtime_set_suspended(&dev->dev);
+       pm_runtime_disable(&dev->dev);
++      pm_runtime_put_noidle(&dev->dev);
++      pm_runtime_set_suspended(&dev->dev);
+ 
+       return 0;
+ }
+diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
+index 509a7fce8f05..2a19d9a37a6a 100644
+--- a/drivers/usb/host/xhci-ring.c
++++ b/drivers/usb/host/xhci-ring.c
+@@ -3331,8 +3331,8 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t 
mem_flags,
+                       /* New sg entry */
+                       --num_sgs;
+                       sent_len -= block_len;
+-                      if (num_sgs != 0) {
+-                              sg = sg_next(sg);
++                      sg = sg_next(sg);
++                      if (num_sgs != 0 && sg) {
+                               block_len = sg_dma_len(sg);
+                               addr = (u64) sg_dma_address(sg);
+                               addr += sent_len;
+diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
+index 8b9471904f67..cb70f0c6aa1b 100644
+--- a/fs/cifs/cifssmb.c
++++ b/fs/cifs/cifssmb.c
+@@ -2051,8 +2051,8 @@ cifs_writev_requeue(struct cifs_writedata *wdata)
+                       }
+               }
+ 
++              kref_put(&wdata2->refcount, cifs_writedata_release);
+               if (rc) {
+-                      kref_put(&wdata2->refcount, cifs_writedata_release);
+                       if (is_retryable_error(rc))
+                               continue;
+                       i += nr_pages;
+diff --git a/fs/exec.c b/fs/exec.c
+index 3818813d725d..cece8c14f377 100644
+--- a/fs/exec.c
++++ b/fs/exec.c
+@@ -1269,6 +1269,8 @@ int flush_old_exec(struct linux_binprm * bprm)
+        */
+       set_mm_exe_file(bprm->mm, bprm->file);
+ 
++      would_dump(bprm, bprm->file);
++
+       /*
+        * Release all of the old mmap stuff
+        */
+@@ -1814,8 +1816,6 @@ static int __do_execve_file(int fd, struct filename 
*filename,
+       if (retval < 0)
+               goto out;
+ 
+-      would_dump(bprm, bprm->file);
+-
+       retval = exec_binprm(bprm);
+       if (retval < 0)
+               goto out;
+diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
+index 096b47972139..43f53020553b 100644
+--- a/fs/gfs2/bmap.c
++++ b/fs/gfs2/bmap.c
+@@ -530,10 +530,12 @@ lower_metapath:
+ 
+               /* Advance in metadata tree. */
+               (mp->mp_list[hgt])++;
+-              if (mp->mp_list[hgt] >= sdp->sd_inptrs) {
+-                      if (!hgt)
++              if (hgt) {
++                      if (mp->mp_list[hgt] >= sdp->sd_inptrs)
++                              goto lower_metapath;
++              } else {
++                      if (mp->mp_list[hgt] >= sdp->sd_diptrs)
+                               break;
+-                      goto lower_metapath;
+               }
+ 
+ fill_up_metapath:
+@@ -879,10 +881,9 @@ static int gfs2_iomap_get(struct inode *inode, loff_t 
pos, loff_t length,
+                                       ret = -ENOENT;
+                                       goto unlock;
+                               } else {
+-                                      /* report a hole */
+                                       iomap->offset = pos;
+                                       iomap->length = length;
+-                                      goto do_alloc;
++                                      goto hole_found;
+                               }
+                       }
+                       iomap->length = size;
+@@ -936,8 +937,6 @@ unlock:
+       return ret;
+ 
+ do_alloc:
+-      iomap->addr = IOMAP_NULL_ADDR;
+-      iomap->type = IOMAP_HOLE;
+       if (flags & IOMAP_REPORT) {
+               if (pos >= size)
+                       ret = -ENOENT;
+@@ -959,6 +958,9 @@ do_alloc:
+               if (pos < size && height == ip->i_height)
+                       ret = gfs2_hole_size(inode, lblock, len, mp, iomap);
+       }
++hole_found:
++      iomap->addr = IOMAP_NULL_ADDR;
++      iomap->type = IOMAP_HOLE;
+       goto out;
+ }
+ 
+diff --git a/fs/nfs/fscache-index.c b/fs/nfs/fscache-index.c
+index 666415d13d52..b7ca0b85b1fe 100644
+--- a/fs/nfs/fscache-index.c
++++ b/fs/nfs/fscache-index.c
+@@ -88,8 +88,10 @@ enum fscache_checkaux nfs_fscache_inode_check_aux(void 
*cookie_netfs_data,
+               return FSCACHE_CHECKAUX_OBSOLETE;
+ 
+       memset(&auxdata, 0, sizeof(auxdata));
+-      auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime);
+-      auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime);
++      auxdata.mtime_sec  = nfsi->vfs_inode.i_mtime.tv_sec;
++      auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec;
++      auxdata.ctime_sec  = nfsi->vfs_inode.i_ctime.tv_sec;
++      auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec;
+ 
+       if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4)
+               auxdata.change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode);
+diff --git a/fs/nfs/fscache.c b/fs/nfs/fscache.c
+index 6f45b1a95739..7dfa45a38088 100644
+--- a/fs/nfs/fscache.c
++++ b/fs/nfs/fscache.c
+@@ -192,7 +192,8 @@ void nfs_fscache_get_super_cookie(struct super_block *sb, 
const char *uniq, int
+       /* create a cache index for looking up filehandles */
+       nfss->fscache = fscache_acquire_cookie(nfss->nfs_client->fscache,
+                                              &nfs_fscache_super_index_def,
+-                                             key, sizeof(*key) + ulen,
++                                             &key->key,
++                                             sizeof(key->key) + ulen,
+                                              NULL, 0,
+                                              nfss, 0, true);
+       dfprintk(FSCACHE, "NFS: get superblock cookie (0x%p/0x%p)\n",
+@@ -230,6 +231,19 @@ void nfs_fscache_release_super_cookie(struct super_block 
*sb)
+       }
+ }
+ 
++static void nfs_fscache_update_auxdata(struct nfs_fscache_inode_auxdata 
*auxdata,
++                                struct nfs_inode *nfsi)
++{
++      memset(auxdata, 0, sizeof(*auxdata));
++      auxdata->mtime_sec  = nfsi->vfs_inode.i_mtime.tv_sec;
++      auxdata->mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec;
++      auxdata->ctime_sec  = nfsi->vfs_inode.i_ctime.tv_sec;
++      auxdata->ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec;
++
++      if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4)
++              auxdata->change_attr = 
inode_peek_iversion_raw(&nfsi->vfs_inode);
++}
++
+ /*
+  * Initialise the per-inode cache cookie pointer for an NFS inode.
+  */
+@@ -243,12 +257,7 @@ void nfs_fscache_init_inode(struct inode *inode)
+       if (!(nfss->fscache && S_ISREG(inode->i_mode)))
+               return;
+ 
+-      memset(&auxdata, 0, sizeof(auxdata));
+-      auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime);
+-      auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime);
+-
+-      if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4)
+-              auxdata.change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode);
++      nfs_fscache_update_auxdata(&auxdata, nfsi);
+ 
+       nfsi->fscache = fscache_acquire_cookie(NFS_SB(inode->i_sb)->fscache,
+                                              &nfs_fscache_inode_object_def,
+@@ -268,9 +277,7 @@ void nfs_fscache_clear_inode(struct inode *inode)
+ 
+       dfprintk(FSCACHE, "NFS: clear cookie (0x%p/0x%p)\n", nfsi, cookie);
+ 
+-      memset(&auxdata, 0, sizeof(auxdata));
+-      auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime);
+-      auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime);
++      nfs_fscache_update_auxdata(&auxdata, nfsi);
+       fscache_relinquish_cookie(cookie, &auxdata, false);
+       nfsi->fscache = NULL;
+ }
+@@ -310,9 +317,7 @@ void nfs_fscache_open_file(struct inode *inode, struct 
file *filp)
+       if (!fscache_cookie_valid(cookie))
+               return;
+ 
+-      memset(&auxdata, 0, sizeof(auxdata));
+-      auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime);
+-      auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime);
++      nfs_fscache_update_auxdata(&auxdata, nfsi);
+ 
+       if (inode_is_open_for_write(inode)) {
+               dfprintk(FSCACHE, "NFS: nfsi 0x%p disabling cache\n", nfsi);
+diff --git a/fs/nfs/fscache.h b/fs/nfs/fscache.h
+index 6363ea956858..89d2f956668f 100644
+--- a/fs/nfs/fscache.h
++++ b/fs/nfs/fscache.h
+@@ -66,9 +66,11 @@ struct nfs_fscache_key {
+  * cache object.
+  */
+ struct nfs_fscache_inode_auxdata {
+-      struct timespec mtime;
+-      struct timespec ctime;
+-      u64             change_attr;
++      s64     mtime_sec;
++      s64     mtime_nsec;
++      s64     ctime_sec;
++      s64     ctime_nsec;
++      u64     change_attr;
+ };
+ 
+ /*
+diff --git a/include/linux/compiler.h b/include/linux/compiler.h
+index 75112aa8064e..fbb6490c1e09 100644
+--- a/include/linux/compiler.h
++++ b/include/linux/compiler.h
+@@ -351,4 +351,10 @@ static inline void *offset_to_ptr(const int *off)
+       compiletime_assert(__native_word(t),                            \
+               "Need native word sized stores/loads for atomicity.")
+ 
++/*
++ * This is needed in functions which generate the stack canary, see
++ * arch/x86/kernel/smpboot.c::start_secondary() for an example.
++ */
++#define prevent_tail_call_optimization()      mb()
++
+ #endif /* __LINUX_COMPILER_H */
+diff --git a/include/linux/fs.h b/include/linux/fs.h
+index 15b8e02880c3..8d568b51778b 100644
+--- a/include/linux/fs.h
++++ b/include/linux/fs.h
+@@ -934,7 +934,7 @@ struct file_handle {
+       __u32 handle_bytes;
+       int handle_type;
+       /* file identifier */
+-      unsigned char f_handle[0];
++      unsigned char f_handle[];
+ };
+ 
+ static inline struct file *get_file(struct file *f)
+diff --git a/include/linux/pnp.h b/include/linux/pnp.h
+index 3b12fd28af78..fc4df3ccefc9 100644
+--- a/include/linux/pnp.h
++++ b/include/linux/pnp.h
+@@ -220,10 +220,8 @@ struct pnp_card {
+ #define global_to_pnp_card(n) list_entry(n, struct pnp_card, global_list)
+ #define protocol_to_pnp_card(n) list_entry(n, struct pnp_card, protocol_list)
+ #define to_pnp_card(n) container_of(n, struct pnp_card, dev)
+-#define pnp_for_each_card(card) \
+-      for((card) = global_to_pnp_card(pnp_cards.next); \
+-      (card) != global_to_pnp_card(&pnp_cards); \
+-      (card) = global_to_pnp_card((card)->global_list.next))
++#define pnp_for_each_card(card)       \
++      list_for_each_entry(card, &pnp_cards, global_list)
+ 
+ struct pnp_card_link {
+       struct pnp_card *card;
+@@ -276,14 +274,9 @@ struct pnp_dev {
+ #define card_to_pnp_dev(n) list_entry(n, struct pnp_dev, card_list)
+ #define protocol_to_pnp_dev(n) list_entry(n, struct pnp_dev, protocol_list)
+ #define       to_pnp_dev(n) container_of(n, struct pnp_dev, dev)
+-#define pnp_for_each_dev(dev) \
+-      for((dev) = global_to_pnp_dev(pnp_global.next); \
+-      (dev) != global_to_pnp_dev(&pnp_global); \
+-      (dev) = global_to_pnp_dev((dev)->global_list.next))
+-#define card_for_each_dev(card,dev) \
+-      for((dev) = card_to_pnp_dev((card)->devices.next); \
+-      (dev) != card_to_pnp_dev(&(card)->devices); \
+-      (dev) = card_to_pnp_dev((dev)->card_list.next))
++#define pnp_for_each_dev(dev) list_for_each_entry(dev, &pnp_global, 
global_list)
++#define card_for_each_dev(card, dev)  \
++      list_for_each_entry(dev, &(card)->devices, card_list)
+ #define pnp_dev_name(dev) (dev)->name
+ 
+ static inline void *pnp_get_drvdata(struct pnp_dev *pdev)
+@@ -437,14 +430,10 @@ struct pnp_protocol {
+ };
+ 
+ #define to_pnp_protocol(n) list_entry(n, struct pnp_protocol, protocol_list)
+-#define protocol_for_each_card(protocol,card) \
+-      for((card) = protocol_to_pnp_card((protocol)->cards.next); \
+-      (card) != protocol_to_pnp_card(&(protocol)->cards); \
+-      (card) = protocol_to_pnp_card((card)->protocol_list.next))
+-#define protocol_for_each_dev(protocol,dev) \
+-      for((dev) = protocol_to_pnp_dev((protocol)->devices.next); \
+-      (dev) != protocol_to_pnp_dev(&(protocol)->devices); \
+-      (dev) = protocol_to_pnp_dev((dev)->protocol_list.next))
++#define protocol_for_each_card(protocol, card)        \
++      list_for_each_entry(card, &(protocol)->cards, protocol_list)
++#define protocol_for_each_dev(protocol, dev)  \
++      list_for_each_entry(dev, &(protocol)->devices, protocol_list)
+ 
+ extern struct bus_type pnp_bus_type;
+ 
+diff --git a/include/linux/tty.h b/include/linux/tty.h
+index 248a137112e8..74226a8f919c 100644
+--- a/include/linux/tty.h
++++ b/include/linux/tty.h
+@@ -66,7 +66,7 @@ struct tty_buffer {
+       int read;
+       int flags;
+       /* Data points here */
+-      unsigned long data[0];
++      unsigned long data[];
+ };
+ 
+ /* Values for .flags field of tty_buffer */
+diff --git a/include/net/netfilter/nf_conntrack.h 
b/include/net/netfilter/nf_conntrack.h
+index f45141bdbb83..ac4d70aeee12 100644
+--- a/include/net/netfilter/nf_conntrack.h
++++ b/include/net/netfilter/nf_conntrack.h
+@@ -85,7 +85,7 @@ struct nf_conn {
+       struct hlist_node       nat_bysource;
+ #endif
+       /* all members below initialized via memset */
+-      u8 __nfct_init_offset[0];
++      struct { } __nfct_init_offset;
+ 
+       /* If we were expected by an expectation, this will be it */
+       struct nf_conn *master;
+diff --git a/include/net/tcp.h b/include/net/tcp.h
+index e43df898d3db..0d4501f44e00 100644
+--- a/include/net/tcp.h
++++ b/include/net/tcp.h
+@@ -1373,6 +1373,19 @@ static inline int tcp_full_space(const struct sock *sk)
+       return tcp_win_from_space(sk, sk->sk_rcvbuf);
+ }
+ 
++/* We provision sk_rcvbuf around 200% of sk_rcvlowat.
++ * If 87.5 % (7/8) of the space has been consumed, we want to override
++ * SO_RCVLOWAT constraint, since we are receiving skbs with too small
++ * len/truesize ratio.
++ */
++static inline bool tcp_rmem_pressure(const struct sock *sk)
++{
++      int rcvbuf = READ_ONCE(sk->sk_rcvbuf);
++      int threshold = rcvbuf - (rcvbuf >> 3);
++
++      return atomic_read(&sk->sk_rmem_alloc) > threshold;
++}
++
+ extern void tcp_openreq_init_rwin(struct request_sock *req,
+                                 const struct sock *sk_listener,
+                                 const struct dst_entry *dst);
+diff --git a/include/sound/rawmidi.h b/include/sound/rawmidi.h
+index c2a71fd8dfaf..1894af415b20 100644
+--- a/include/sound/rawmidi.h
++++ b/include/sound/rawmidi.h
+@@ -76,6 +76,7 @@ struct snd_rawmidi_runtime {
+       size_t avail_min;       /* min avail for wakeup */
+       size_t avail;           /* max used buffer for wakeup */
+       size_t xruns;           /* over/underruns counter */
++      int buffer_ref;         /* buffer reference count */
+       /* misc */
+       spinlock_t lock;
+       wait_queue_head_t sleep;
+diff --git a/init/main.c b/init/main.c
+index 38a603f62b7b..ec78f2312610 100644
+--- a/init/main.c
++++ b/init/main.c
+@@ -735,6 +735,8 @@ asmlinkage __visible void __init start_kernel(void)
+ 
+       /* Do the rest non-__init'ed, we're now alive */
+       rest_init();
++
++      prevent_tail_call_optimization();
+ }
+ 
+ /* Call all constructor functions linked into the kernel. */
+diff --git a/ipc/util.c b/ipc/util.c
+index b111e792b312..af1b572effb1 100644
+--- a/ipc/util.c
++++ b/ipc/util.c
+@@ -735,21 +735,21 @@ static struct kern_ipc_perm *sysvipc_find_ipc(struct 
ipc_ids *ids, loff_t pos,
+                       total++;
+       }
+ 
+-      *new_pos = pos + 1;
++      ipc = NULL;
+       if (total >= ids->in_use)
+-              return NULL;
++              goto out;
+ 
+       for (; pos < IPCMNI; pos++) {
+               ipc = idr_find(&ids->ipcs_idr, pos);
+               if (ipc != NULL) {
+                       rcu_read_lock();
+                       ipc_lock_object(ipc);
+-                      return ipc;
++                      break;
+               }
+       }
+-
+-      /* Out of range - return NULL to terminate iteration */
+-      return NULL;
++out:
++      *new_pos = pos + 1;
++      return ipc;
+ }
+ 
+ static void *sysvipc_proc_next(struct seq_file *s, void *it, loff_t *pos)
+diff --git a/mm/shmem.c b/mm/shmem.c
+index 0a2e1e7801d6..dea5120565d3 100644
+--- a/mm/shmem.c
++++ b/mm/shmem.c
+@@ -2149,7 +2149,11 @@ int shmem_lock(struct file *file, int lock, struct 
user_struct *user)
+       struct shmem_inode_info *info = SHMEM_I(inode);
+       int retval = -ENOMEM;
+ 
+-      spin_lock_irq(&info->lock);
++      /*
++       * What serializes the accesses to info->flags?
++       * ipc_lock_object() when called from shmctl_do_lock(),
++       * no serialization needed when called from shm_destroy().
++       */
+       if (lock && !(info->flags & VM_LOCKED)) {
+               if (!user_shm_lock(inode->i_size, user))
+                       goto out_nomem;
+@@ -2164,7 +2168,6 @@ int shmem_lock(struct file *file, int lock, struct 
user_struct *user)
+       retval = 0;
+ 
+ out_nomem:
+-      spin_unlock_irq(&info->lock);
+       return retval;
+ }
+ 
+diff --git a/net/core/dev.c b/net/core/dev.c
+index 426635e188fc..9ccc14200b80 100644
+--- a/net/core/dev.c
++++ b/net/core/dev.c
+@@ -8259,11 +8259,13 @@ static void netdev_sync_lower_features(struct 
net_device *upper,
+                       netdev_dbg(upper, "Disabling feature %pNF on lower dev 
%s.\n",
+                                  &feature, lower->name);
+                       lower->wanted_features &= ~feature;
+-                      netdev_update_features(lower);
++                      __netdev_update_features(lower);
+ 
+                       if (unlikely(lower->features & feature))
+                               netdev_WARN(upper, "failed to disable %pNF on 
%s!\n",
+                                           &feature, lower->name);
++                      else
++                              netdev_features_change(lower);
+               }
+       }
+ }
+diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
+index c7785efeea57..3978a5e8d261 100644
+--- a/net/core/drop_monitor.c
++++ b/net/core/drop_monitor.c
+@@ -154,6 +154,7 @@ static void sched_send_work(struct timer_list *t)
+ static void trace_drop_common(struct sk_buff *skb, void *location)
+ {
+       struct net_dm_alert_msg *msg;
++      struct net_dm_drop_point *point;
+       struct nlmsghdr *nlh;
+       struct nlattr *nla;
+       int i;
+@@ -172,11 +173,13 @@ static void trace_drop_common(struct sk_buff *skb, void 
*location)
+       nlh = (struct nlmsghdr *)dskb->data;
+       nla = genlmsg_data(nlmsg_data(nlh));
+       msg = nla_data(nla);
++      point = msg->points;
+       for (i = 0; i < msg->entries; i++) {
+-              if (!memcmp(&location, msg->points[i].pc, sizeof(void *))) {
+-                      msg->points[i].count++;
++              if (!memcmp(&location, &point->pc, sizeof(void *))) {
++                      point->count++;
+                       goto out;
+               }
++              point++;
+       }
+       if (msg->entries == dm_hit_limit)
+               goto out;
+@@ -185,8 +188,8 @@ static void trace_drop_common(struct sk_buff *skb, void 
*location)
+        */
+       __nla_reserve_nohdr(dskb, sizeof(struct net_dm_drop_point));
+       nla->nla_len += NLA_ALIGN(sizeof(struct net_dm_drop_point));
+-      memcpy(msg->points[msg->entries].pc, &location, sizeof(void *));
+-      msg->points[msg->entries].count = 1;
++      memcpy(point->pc, &location, sizeof(void *));
++      point->count = 1;
+       msg->entries++;
+ 
+       if (!timer_pending(&data->send_timer)) {
+diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
+index b9057478d69c..239786608ee4 100644
+--- a/net/core/netprio_cgroup.c
++++ b/net/core/netprio_cgroup.c
+@@ -240,6 +240,8 @@ static void net_prio_attach(struct cgroup_taskset *tset)
+       struct task_struct *p;
+       struct cgroup_subsys_state *css;
+ 
++      cgroup_sk_alloc_disable();
++
+       cgroup_taskset_for_each(p, css, tset) {
+               void *v = (void *)(unsigned long)css->cgroup->id;
+ 
+diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
+index 46ae4dee522a..b036c55f5cb1 100644
+--- a/net/dsa/dsa2.c
++++ b/net/dsa/dsa2.c
+@@ -412,7 +412,7 @@ static int dsa_tree_setup_switches(struct dsa_switch_tree 
*dst)
+ 
+               err = dsa_switch_setup(ds);
+               if (err)
+-                      return err;
++                      continue;
+ 
+               for (port = 0; port < ds->num_ports; port++) {
+                       dp = &ds->ports[port];
+diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
+index 1c21dc5d6dd4..5535b722f66d 100644
+--- a/net/ipv4/cipso_ipv4.c
++++ b/net/ipv4/cipso_ipv4.c
+@@ -1272,7 +1272,8 @@ static int cipso_v4_parsetag_rbm(const struct 
cipso_v4_doi *doi_def,
+                       return ret_val;
+               }
+ 
+-              secattr->flags |= NETLBL_SECATTR_MLS_CAT;
++              if (secattr->attr.mls.cat)
++                      secattr->flags |= NETLBL_SECATTR_MLS_CAT;
+       }
+ 
+       return 0;
+@@ -1453,7 +1454,8 @@ static int cipso_v4_parsetag_rng(const struct 
cipso_v4_doi *doi_def,
+                       return ret_val;
+               }
+ 
+-              secattr->flags |= NETLBL_SECATTR_MLS_CAT;
++              if (secattr->attr.mls.cat)
++                      secattr->flags |= NETLBL_SECATTR_MLS_CAT;
+       }
+ 
+       return 0;
+diff --git a/net/ipv4/route.c b/net/ipv4/route.c
+index 4590af506244..84ddb16f4fc0 100644
+--- a/net/ipv4/route.c
++++ b/net/ipv4/route.c
+@@ -906,7 +906,7 @@ void ip_rt_send_redirect(struct sk_buff *skb)
+       /* Check for load limit; set rate_last to the latest sent
+        * redirect.
+        */
+-      if (peer->rate_tokens == 0 ||
++      if (peer->n_redirects == 0 ||
+           time_after(jiffies,
+                      (peer->rate_last +
+                       (ip_rt_redirect_load << peer->n_redirects)))) {
+diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
+index 54dda47a9a56..d31a4f5d25e8 100644
+--- a/net/ipv4/tcp.c
++++ b/net/ipv4/tcp.c
+@@ -488,9 +488,17 @@ static void tcp_tx_timestamp(struct sock *sk, u16 tsflags)
+ static inline bool tcp_stream_is_readable(const struct tcp_sock *tp,
+                                         int target, struct sock *sk)
+ {
+-      return (READ_ONCE(tp->rcv_nxt) - tp->copied_seq >= target) ||
+-              (sk->sk_prot->stream_memory_read ?
+-              sk->sk_prot->stream_memory_read(sk) : false);
++      int avail = READ_ONCE(tp->rcv_nxt) - READ_ONCE(tp->copied_seq);
++
++      if (avail > 0) {
++              if (avail >= target)
++                      return true;
++              if (tcp_rmem_pressure(sk))
++                      return true;
++      }
++      if (sk->sk_prot->stream_memory_read)
++              return sk->sk_prot->stream_memory_read(sk);
++      return false;
+ }
+ 
+ /*
+@@ -1774,10 +1782,11 @@ static int tcp_zerocopy_receive(struct sock *sk,
+ 
+       down_read(&current->mm->mmap_sem);
+ 
+-      ret = -EINVAL;
+       vma = find_vma(current->mm, address);
+-      if (!vma || vma->vm_start > address || vma->vm_ops != &tcp_vm_ops)
+-              goto out;
++      if (!vma || vma->vm_start > address || vma->vm_ops != &tcp_vm_ops) {
++              up_read(&current->mm->mmap_sem);
++              return -EINVAL;
++      }
+       zc->length = min_t(unsigned long, zc->length, vma->vm_end - address);
+ 
+       tp = tcp_sk(sk);
+@@ -2134,14 +2143,16 @@ skip_copy:
+                       tp->urg_data = 0;
+                       tcp_fast_path_check(sk);
+               }
+-              if (used + offset < skb->len)
+-                      continue;
+ 
+               if (TCP_SKB_CB(skb)->has_rxtstamp) {
+                       tcp_update_recv_tstamps(skb, &tss);
+                       has_tss = true;
+                       has_cmsg = true;
+               }
++
++              if (used + offset < skb->len)
++                      continue;
++
+               if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)
+                       goto found_fin_ok;
+               if (!(flags & MSG_PEEK))
+diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
+index 38b6d8f90a44..12e1ea7344d9 100644
+--- a/net/ipv4/tcp_input.c
++++ b/net/ipv4/tcp_input.c
+@@ -4683,7 +4683,8 @@ void tcp_data_ready(struct sock *sk)
+       const struct tcp_sock *tp = tcp_sk(sk);
+       int avail = tp->rcv_nxt - tp->copied_seq;
+ 
+-      if (avail < sk->sk_rcvlowat && !sock_flag(sk, SOCK_DONE))
++      if (avail < sk->sk_rcvlowat && !tcp_rmem_pressure(sk) &&
++          !sock_flag(sk, SOCK_DONE))
+               return;
+ 
+       sk->sk_data_ready(sk);
+diff --git a/net/ipv6/calipso.c b/net/ipv6/calipso.c
+index 1c0bb9fb76e6..70611784c071 100644
+--- a/net/ipv6/calipso.c
++++ b/net/ipv6/calipso.c
+@@ -1061,7 +1061,8 @@ static int calipso_opt_getattr(const unsigned char 
*calipso,
+                       goto getattr_return;
+               }
+ 
+-              secattr->flags |= NETLBL_SECATTR_MLS_CAT;
++              if (secattr->attr.mls.cat)
++                      secattr->flags |= NETLBL_SECATTR_MLS_CAT;
+       }
+ 
+       secattr->type = NETLBL_NLTYPE_CALIPSO;
+diff --git a/net/ipv6/route.c b/net/ipv6/route.c
+index 9c36a743ddbc..dad35cd48807 100644
+--- a/net/ipv6/route.c
++++ b/net/ipv6/route.c
+@@ -2360,8 +2360,10 @@ static void __ip6_rt_update_pmtu(struct dst_entry *dst, 
const struct sock *sk,
+       const struct in6_addr *daddr, *saddr;
+       struct rt6_info *rt6 = (struct rt6_info *)dst;
+ 
+-      if (dst_metric_locked(dst, RTAX_MTU))
+-              return;
++      /* Note: do *NOT* check dst_metric_locked(dst, RTAX_MTU)
++       * IPv6 pmtu discovery isn't optional, so 'mtu lock' cannot disable it.
++       * [see also comment in rt6_mtu_change_route()]
++       */
+ 
+       if (iph) {
+               daddr = &iph->daddr;
+diff --git a/net/netfilter/nf_conntrack_core.c 
b/net/netfilter/nf_conntrack_core.c
+index c6073d17c324..ad1da6b2fb60 100644
+--- a/net/netfilter/nf_conntrack_core.c
++++ b/net/netfilter/nf_conntrack_core.c
+@@ -1352,9 +1352,9 @@ __nf_conntrack_alloc(struct net *net,
+       *(unsigned long *)(&ct->tuplehash[IP_CT_DIR_REPLY].hnnode.pprev) = hash;
+       ct->status = 0;
+       write_pnet(&ct->ct_net, net);
+-      memset(&ct->__nfct_init_offset[0], 0,
++      memset(&ct->__nfct_init_offset, 0,
+              offsetof(struct nf_conn, proto) -
+-             offsetof(struct nf_conn, __nfct_init_offset[0]));
++             offsetof(struct nf_conn, __nfct_init_offset));
+ 
+       nf_ct_zone_add(ct, zone);
+ 
+diff --git a/net/netfilter/nft_set_rbtree.c b/net/netfilter/nft_set_rbtree.c
+index 0221510328d4..84d317418d18 100644
+--- a/net/netfilter/nft_set_rbtree.c
++++ b/net/netfilter/nft_set_rbtree.c
+@@ -36,6 +36,11 @@ static bool nft_rbtree_interval_end(const struct 
nft_rbtree_elem *rbe)
+              (*nft_set_ext_flags(&rbe->ext) & NFT_SET_ELEM_INTERVAL_END);
+ }
+ 
++static bool nft_rbtree_interval_start(const struct nft_rbtree_elem *rbe)
++{
++      return !nft_rbtree_interval_end(rbe);
++}
++
+ static bool nft_rbtree_equal(const struct nft_set *set, const void *this,
+                            const struct nft_rbtree_elem *interval)
+ {
+@@ -67,7 +72,7 @@ static bool __nft_rbtree_lookup(const struct net *net, const 
struct nft_set *set
+                       if (interval &&
+                           nft_rbtree_equal(set, this, interval) &&
+                           nft_rbtree_interval_end(rbe) &&
+-                          !nft_rbtree_interval_end(interval))
++                          nft_rbtree_interval_start(interval))
+                               continue;
+                       interval = rbe;
+               } else if (d > 0)
+@@ -92,7 +97,7 @@ static bool __nft_rbtree_lookup(const struct net *net, const 
struct nft_set *set
+ 
+       if (set->flags & NFT_SET_INTERVAL && interval != NULL &&
+           nft_set_elem_active(&interval->ext, genmask) &&
+-          !nft_rbtree_interval_end(interval)) {
++          nft_rbtree_interval_start(interval)) {
+               *ext = &interval->ext;
+               return true;
+       }
+@@ -221,9 +226,9 @@ static int __nft_rbtree_insert(const struct net *net, 
const struct nft_set *set,
+                       p = &parent->rb_right;
+               else {
+                       if (nft_rbtree_interval_end(rbe) &&
+-                          !nft_rbtree_interval_end(new)) {
++                          nft_rbtree_interval_start(new)) {
+                               p = &parent->rb_left;
+-                      } else if (!nft_rbtree_interval_end(rbe) &&
++                      } else if (nft_rbtree_interval_start(rbe) &&
+                                  nft_rbtree_interval_end(new)) {
+                               p = &parent->rb_right;
+                       } else if (nft_set_elem_active(&rbe->ext, genmask)) {
+@@ -314,10 +319,10 @@ static void *nft_rbtree_deactivate(const struct net *net,
+                       parent = parent->rb_right;
+               else {
+                       if (nft_rbtree_interval_end(rbe) &&
+-                          !nft_rbtree_interval_end(this)) {
++                          nft_rbtree_interval_start(this)) {
+                               parent = parent->rb_left;
+                               continue;
+-                      } else if (!nft_rbtree_interval_end(rbe) &&
++                      } else if (nft_rbtree_interval_start(rbe) &&
+                                  nft_rbtree_interval_end(this)) {
+                               parent = parent->rb_right;
+                               continue;
+diff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c
+index ee3e5b6471a6..15fe2120b310 100644
+--- a/net/netlabel/netlabel_kapi.c
++++ b/net/netlabel/netlabel_kapi.c
+@@ -748,6 +748,12 @@ int netlbl_catmap_getlong(struct netlbl_lsm_catmap 
*catmap,
+       if ((off & (BITS_PER_LONG - 1)) != 0)
+               return -EINVAL;
+ 
++      /* a null catmap is equivalent to an empty one */
++      if (!catmap) {
++              *offset = (u32)-1;
++              return 0;
++      }
++
+       if (off < catmap->startbit) {
+               off = catmap->startbit;
+               *offset = off;
+diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
+index a52d6d16efc4..9b26973fe697 100644
+--- a/sound/core/rawmidi.c
++++ b/sound/core/rawmidi.c
+@@ -112,6 +112,17 @@ static void snd_rawmidi_input_event_work(struct 
work_struct *work)
+               runtime->event(runtime->substream);
+ }
+ 
++/* buffer refcount management: call with runtime->lock held */
++static inline void snd_rawmidi_buffer_ref(struct snd_rawmidi_runtime *runtime)
++{
++      runtime->buffer_ref++;
++}
++
++static inline void snd_rawmidi_buffer_unref(struct snd_rawmidi_runtime 
*runtime)
++{
++      runtime->buffer_ref--;
++}
++
+ static int snd_rawmidi_runtime_create(struct snd_rawmidi_substream *substream)
+ {
+       struct snd_rawmidi_runtime *runtime;
+@@ -661,6 +672,11 @@ static int resize_runtime_buffer(struct 
snd_rawmidi_runtime *runtime,
+               if (!newbuf)
+                       return -ENOMEM;
+               spin_lock_irq(&runtime->lock);
++              if (runtime->buffer_ref) {
++                      spin_unlock_irq(&runtime->lock);
++                      kvfree(newbuf);
++                      return -EBUSY;
++              }
+               oldbuf = runtime->buffer;
+               runtime->buffer = newbuf;
+               runtime->buffer_size = params->buffer_size;
+@@ -960,8 +976,10 @@ static long snd_rawmidi_kernel_read1(struct 
snd_rawmidi_substream *substream,
+       long result = 0, count1;
+       struct snd_rawmidi_runtime *runtime = substream->runtime;
+       unsigned long appl_ptr;
++      int err = 0;
+ 
+       spin_lock_irqsave(&runtime->lock, flags);
++      snd_rawmidi_buffer_ref(runtime);
+       while (count > 0 && runtime->avail) {
+               count1 = runtime->buffer_size - runtime->appl_ptr;
+               if (count1 > count)
+@@ -980,16 +998,19 @@ static long snd_rawmidi_kernel_read1(struct 
snd_rawmidi_substream *substream,
+               if (userbuf) {
+                       spin_unlock_irqrestore(&runtime->lock, flags);
+                       if (copy_to_user(userbuf + result,
+-                                       runtime->buffer + appl_ptr, count1)) {
+-                              return result > 0 ? result : -EFAULT;
+-                      }
++                                       runtime->buffer + appl_ptr, count1))
++                              err = -EFAULT;
+                       spin_lock_irqsave(&runtime->lock, flags);
++                      if (err)
++                              goto out;
+               }
+               result += count1;
+               count -= count1;
+       }
++ out:
++      snd_rawmidi_buffer_unref(runtime);
+       spin_unlock_irqrestore(&runtime->lock, flags);
+-      return result;
++      return result > 0 ? result : err;
+ }
+ 
+ long snd_rawmidi_kernel_read(struct snd_rawmidi_substream *substream,
+@@ -1261,6 +1282,7 @@ static long snd_rawmidi_kernel_write1(struct 
snd_rawmidi_substream *substream,
+                       return -EAGAIN;
+               }
+       }
++      snd_rawmidi_buffer_ref(runtime);
+       while (count > 0 && runtime->avail > 0) {
+               count1 = runtime->buffer_size - runtime->appl_ptr;
+               if (count1 > count)
+@@ -1292,6 +1314,7 @@ static long snd_rawmidi_kernel_write1(struct 
snd_rawmidi_substream *substream,
+       }
+       __end:
+       count1 = runtime->avail < runtime->buffer_size;
++      snd_rawmidi_buffer_unref(runtime);
+       spin_unlock_irqrestore(&runtime->lock, flags);
+       if (count1)
+               snd_rawmidi_output_trigger(substream, 1);
+diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
+index 12a064f994b1..1d83c3c59e1a 100644
+--- a/sound/pci/hda/patch_hdmi.c
++++ b/sound/pci/hda/patch_hdmi.c
+@@ -2211,7 +2211,9 @@ static int generic_hdmi_build_controls(struct hda_codec 
*codec)
+ 
+       for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
+               struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
++              struct hdmi_eld *pin_eld = &per_pin->sink_eld;
+ 
++              pin_eld->eld_valid = false;
+               hdmi_present_sense(per_pin, 0);
+       }
+ 
+diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
+index fc39550f6c5d..ffe1340890c9 100644
+--- a/sound/pci/hda/patch_realtek.c
++++ b/sound/pci/hda/patch_realtek.c
+@@ -5524,6 +5524,15 @@ static void 
alc233_alc662_fixup_lenovo_dual_codecs(struct hda_codec *codec,
+       }
+ }
+ 
++static void alc225_fixup_s3_pop_noise(struct hda_codec *codec,
++                                    const struct hda_fixup *fix, int action)
++{
++      if (action != HDA_FIXUP_ACT_PRE_PROBE)
++              return;
++
++      codec->power_save_node = 1;
++}
++
+ /* Forcibly assign NID 0x03 to HP/LO while NID 0x02 to SPK for EQ */
+ static void alc274_fixup_bind_dacs(struct hda_codec *codec,
+                                   const struct hda_fixup *fix, int action)
+@@ -5607,6 +5616,7 @@ enum {
+       ALC269_FIXUP_HP_LINE1_MIC1_LED,
+       ALC269_FIXUP_INV_DMIC,
+       ALC269_FIXUP_LENOVO_DOCK,
++      ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST,
+       ALC269_FIXUP_NO_SHUTUP,
+       ALC286_FIXUP_SONY_MIC_NO_PRESENCE,
+       ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
+@@ -5690,6 +5700,7 @@ enum {
+       ALC233_FIXUP_ACER_HEADSET_MIC,
+       ALC294_FIXUP_LENOVO_MIC_LOCATION,
+       ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE,
++      ALC225_FIXUP_S3_POP_NOISE,
+       ALC700_FIXUP_INTEL_REFERENCE,
+       ALC274_FIXUP_DELL_BIND_DACS,
+       ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
+@@ -5918,6 +5929,12 @@ static const struct hda_fixup alc269_fixups[] = {
+               .chained = true,
+               .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
+       },
++      [ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST] = {
++              .type = HDA_FIXUP_FUNC,
++              .v.func = alc269_fixup_limit_int_mic_boost,
++              .chained = true,
++              .chain_id = ALC269_FIXUP_LENOVO_DOCK,
++      },
+       [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
+               .type = HDA_FIXUP_FUNC,
+               .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
+@@ -6546,6 +6563,12 @@ static const struct hda_fixup alc269_fixups[] = {
+                       { }
+               },
+               .chained = true,
++              .chain_id = ALC225_FIXUP_S3_POP_NOISE
++      },
++      [ALC225_FIXUP_S3_POP_NOISE] = {
++              .type = HDA_FIXUP_FUNC,
++              .v.func = alc225_fixup_s3_pop_noise,
++              .chained = true,
+               .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
+       },
+       [ALC700_FIXUP_INTEL_REFERENCE] = {
+@@ -6997,7 +7020,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
+       SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", 
ALC269_FIXUP_SKU_IGNORE),
+       SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
+       SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", 
ALC269_FIXUP_SKU_IGNORE),
+-      SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", 
ALC269_FIXUP_LENOVO_DOCK),
++      SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", 
ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST),
+       SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", 
ALC269_FIXUP_LENOVO_DOCK),
+       SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", 
ALC269_FIXUP_LENOVO_DOCK),
+       SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", 
ALC269_FIXUP_LENOVO_DOCK),
+@@ -7134,6 +7157,7 @@ static const struct hda_model_fixup 
alc269_fixup_models[] = {
+       {.id = ALC269_FIXUP_HEADSET_MODE, .name = "headset-mode"},
+       {.id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC, .name = 
"headset-mode-no-hp-mic"},
+       {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
++      {.id = ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST, .name = 
"lenovo-dock-limit-boost"},
+       {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
+       {.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = 
"hp-dock-gpio-mic1-led"},
+       {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = 
"dell-headset-multi"},
+@@ -7803,8 +7827,6 @@ static int patch_alc269(struct hda_codec *codec)
+               spec->gen.mixer_nid = 0;
+               break;
+       case 0x10ec0225:
+-              codec->power_save_node = 1;
+-              /* fall through */
+       case 0x10ec0295:
+       case 0x10ec0299:
+               spec->codec_variant = ALC269_TYPE_ALC225;
+diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
+index 6836f827965c..aac23acfdd36 100644
+--- a/sound/usb/quirks.c
++++ b/sound/usb/quirks.c
+@@ -1334,13 +1334,14 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, 
unsigned int pipe,
+           && (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
+               msleep(20);
+ 
+-      /* Zoom R16/24, Logitech H650e, Jabra 550a needs a tiny delay here,
+-       * otherwise requests like get/set frequency return as failed despite
+-       * actually succeeding.
++      /* Zoom R16/24, Logitech H650e, Jabra 550a, Kingston HyperX needs a tiny
++       * delay here, otherwise requests like get/set frequency return as
++       * failed despite actually succeeding.
+        */
+       if ((chip->usb_id == USB_ID(0x1686, 0x00dd) ||
+            chip->usb_id == USB_ID(0x046d, 0x0a46) ||
+-           chip->usb_id == USB_ID(0x0b0e, 0x0349)) &&
++           chip->usb_id == USB_ID(0x0b0e, 0x0349) ||
++           chip->usb_id == USB_ID(0x0951, 0x16ad)) &&
+           (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
+               usleep_range(1000, 2000);
+ }

Reply via email to