diff --git a/Makefile b/Makefile
index d60795319d8a..0b996e9d2c5f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 VERSION = 4
 PATCHLEVEL = 9
-SUBLEVEL = 179
+SUBLEVEL = 180
 EXTRAVERSION =
 NAME = Roaring Lionus
 
diff --git a/arch/arm/include/asm/cp15.h b/arch/arm/include/asm/cp15.h
index b74b174ac9fc..b458e4122794 100644
--- a/arch/arm/include/asm/cp15.h
+++ b/arch/arm/include/asm/cp15.h
@@ -67,6 +67,8 @@
 #define BPIALL                         __ACCESS_CP15(c7, 0, c5, 6)
 #define ICIALLU                                __ACCESS_CP15(c7, 0, c5, 0)
 
+#define CNTVCT                         __ACCESS_CP15_64(1, c14)
+
 extern unsigned long cr_alignment;     /* defined in entry-armv.S */
 
 static inline unsigned long get_cr(void)
diff --git a/arch/arm/vdso/vgettimeofday.c b/arch/arm/vdso/vgettimeofday.c
index 79214d5ff097..3af02d2a0b7f 100644
--- a/arch/arm/vdso/vgettimeofday.c
+++ b/arch/arm/vdso/vgettimeofday.c
@@ -18,9 +18,9 @@
 #include <linux/compiler.h>
 #include <linux/hrtimer.h>
 #include <linux/time.h>
-#include <asm/arch_timer.h>
 #include <asm/barrier.h>
 #include <asm/bug.h>
+#include <asm/cp15.h>
 #include <asm/page.h>
 #include <asm/unistd.h>
 #include <asm/vdso_datapage.h>
@@ -123,7 +123,8 @@ static notrace u64 get_ns(struct vdso_data *vdata)
        u64 cycle_now;
        u64 nsec;
 
-       cycle_now = arch_counter_get_cntvct();
+       isb();
+       cycle_now = read_sysreg(CNTVCT);
 
        cycle_delta = (cycle_now - vdata->cs_cycle_last) & vdata->cs_mask;
 
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 3a30a3994e4a..73e3718356b0 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -413,6 +413,8 @@ static inline phys_addr_t pmd_page_paddr(pmd_t pmd)
        return pmd_val(pmd) & PHYS_MASK & (s32)PAGE_MASK;
 }
 
+static inline void pte_unmap(pte_t *pte) { }
+
 /* Find an entry in the third-level page table. */
 #define pte_index(addr)                (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE 
- 1))
 
@@ -421,7 +423,6 @@ static inline phys_addr_t pmd_page_paddr(pmd_t pmd)
 
 #define pte_offset_map(dir,addr)       pte_offset_kernel((dir), (addr))
 #define pte_offset_map_nested(dir,addr)        pte_offset_kernel((dir), (addr))
-#define pte_unmap(pte)                 do { } while (0)
 #define pte_unmap_nested(pte)          do { } while (0)
 
 #define pte_set_fixmap(addr)           ((pte_t *)set_fixmap_offset(FIX_PTE, 
addr))
diff --git a/arch/arm64/include/asm/vdso_datapage.h 
b/arch/arm64/include/asm/vdso_datapage.h
index 2b9a63771eda..f89263c8e11a 100644
--- a/arch/arm64/include/asm/vdso_datapage.h
+++ b/arch/arm64/include/asm/vdso_datapage.h
@@ -38,6 +38,7 @@ struct vdso_data {
        __u32 tz_minuteswest;   /* Whacky timezone stuff */
        __u32 tz_dsttime;
        __u32 use_syscall;
+       __u32 hrtimer_res;
 };
 
 #endif /* !__ASSEMBLY__ */
diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c
index bd239b1b7a68..95878bea27f9 100644
--- a/arch/arm64/kernel/asm-offsets.c
+++ b/arch/arm64/kernel/asm-offsets.c
@@ -92,7 +92,7 @@ int main(void)
   DEFINE(CLOCK_REALTIME,       CLOCK_REALTIME);
   DEFINE(CLOCK_MONOTONIC,      CLOCK_MONOTONIC);
   DEFINE(CLOCK_MONOTONIC_RAW,  CLOCK_MONOTONIC_RAW);
-  DEFINE(CLOCK_REALTIME_RES,   MONOTONIC_RES_NSEC);
+  DEFINE(CLOCK_REALTIME_RES,   offsetof(struct vdso_data, hrtimer_res));
   DEFINE(CLOCK_REALTIME_COARSE,        CLOCK_REALTIME_COARSE);
   DEFINE(CLOCK_MONOTONIC_COARSE,CLOCK_MONOTONIC_COARSE);
   DEFINE(CLOCK_COARSE_RES,     LOW_RES_NSEC);
diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c
index e137ceaf5016..82b465207ed0 100644
--- a/arch/arm64/kernel/cpu_ops.c
+++ b/arch/arm64/kernel/cpu_ops.c
@@ -85,6 +85,7 @@ static const char *__init cpu_read_enable_method(int cpu)
                                pr_err("%s: missing enable-method property\n",
                                        dn->full_name);
                }
+               of_node_put(dn);
        } else {
                enable_method = acpi_get_enable_method(cpu);
                if (!enable_method) {
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 4bcfe01b5aad..c9b9a5a322eb 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -213,6 +213,9 @@ void update_vsyscall(struct timekeeper *tk)
        vdso_data->wtm_clock_sec                = tk->wall_to_monotonic.tv_sec;
        vdso_data->wtm_clock_nsec               = tk->wall_to_monotonic.tv_nsec;
 
+       /* Read without the seqlock held by clock_getres() */
+       WRITE_ONCE(vdso_data->hrtimer_res, hrtimer_resolution);
+
        if (!use_syscall) {
                /* tkr_mono.cycle_last == tkr_raw.cycle_last */
                vdso_data->cs_cycle_last        = tk->tkr_mono.cycle_last;
diff --git a/arch/arm64/kernel/vdso/gettimeofday.S 
b/arch/arm64/kernel/vdso/gettimeofday.S
index 76320e920965..df829c4346fa 100644
--- a/arch/arm64/kernel/vdso/gettimeofday.S
+++ b/arch/arm64/kernel/vdso/gettimeofday.S
@@ -301,13 +301,14 @@ ENTRY(__kernel_clock_getres)
        ccmp    w0, #CLOCK_MONOTONIC_RAW, #0x4, ne
        b.ne    1f
 
-       ldr     x2, 5f
+       adr     vdso_data, _vdso_data
+       ldr     w2, [vdso_data, #CLOCK_REALTIME_RES]
        b       2f
 1:
        cmp     w0, #CLOCK_REALTIME_COARSE
        ccmp    w0, #CLOCK_MONOTONIC_COARSE, #0x4, ne
        b.ne    4f
-       ldr     x2, 6f
+       ldr     x2, 5f
 2:
        cbz     w1, 3f
        stp     xzr, x2, [x1]
@@ -321,8 +322,6 @@ ENTRY(__kernel_clock_getres)
        svc     #0
        ret
 5:
-       .quad   CLOCK_REALTIME_RES
-6:
        .quad   CLOCK_COARSE_RES
        .cfi_endproc
 ENDPROC(__kernel_clock_getres)
diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S
index f5fde8d389c9..3ceec224d3d2 100644
--- a/arch/arm64/mm/proc.S
+++ b/arch/arm64/mm/proc.S
@@ -64,17 +64,18 @@ ENTRY(cpu_do_suspend)
        mrs     x2, tpidr_el0
        mrs     x3, tpidrro_el0
        mrs     x4, contextidr_el1
-       mrs     x5, cpacr_el1
-       mrs     x6, tcr_el1
-       mrs     x7, vbar_el1
-       mrs     x8, mdscr_el1
-       mrs     x9, oslsr_el1
-       mrs     x10, sctlr_el1
+       mrs     x5, osdlr_el1
+       mrs     x6, cpacr_el1
+       mrs     x7, tcr_el1
+       mrs     x8, vbar_el1
+       mrs     x9, mdscr_el1
+       mrs     x10, oslsr_el1
+       mrs     x11, sctlr_el1
        stp     x2, x3, [x0]
-       stp     x4, xzr, [x0, #16]
-       stp     x5, x6, [x0, #32]
-       stp     x7, x8, [x0, #48]
-       stp     x9, x10, [x0, #64]
+       stp     x4, x5, [x0, #16]
+       stp     x6, x7, [x0, #32]
+       stp     x8, x9, [x0, #48]
+       stp     x10, x11, [x0, #64]
        ret
 ENDPROC(cpu_do_suspend)
 
@@ -96,8 +97,8 @@ ENTRY(cpu_do_resume)
        msr     cpacr_el1, x6
 
        /* Don't change t0sz here, mask those bits when restoring */
-       mrs     x5, tcr_el1
-       bfi     x8, x5, TCR_T0SZ_OFFSET, TCR_TxSZ_WIDTH
+       mrs     x7, tcr_el1
+       bfi     x8, x7, TCR_T0SZ_OFFSET, TCR_TxSZ_WIDTH
 
        msr     tcr_el1, x8
        msr     vbar_el1, x9
@@ -115,6 +116,7 @@ ENTRY(cpu_do_resume)
        /*
         * Restore oslsr_el1 by writing oslar_el1
         */
+       msr     osdlr_el1, x5
        ubfx    x11, x11, #1, #1
        msr     oslar_el1, x11
        reset_pmuserenr_el0 x0                  // Disable PMU access from EL0
diff --git a/arch/powerpc/boot/addnote.c b/arch/powerpc/boot/addnote.c
index 9d9f6f334d3c..3da3e2b1b51b 100644
--- a/arch/powerpc/boot/addnote.c
+++ b/arch/powerpc/boot/addnote.c
@@ -223,7 +223,11 @@ main(int ac, char **av)
        PUT_16(E_PHNUM, np + 2);
 
        /* write back */
-       lseek(fd, (long) 0, SEEK_SET);
+       i = lseek(fd, (long) 0, SEEK_SET);
+       if (i < 0) {
+               perror("lseek");
+               exit(1);
+       }
        i = write(fd, buf, n);
        if (i < 0) {
                perror("write");
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 9cad2ed812ab..31e9064ba628 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -1574,6 +1574,9 @@ int start_topology_update(void)
 {
        int rc = 0;
 
+       if (!topology_updates_enabled)
+               return 0;
+
        if (firmware_has_feature(FW_FEATURE_PRRN)) {
                if (!prrn_enabled) {
                        prrn_enabled = 1;
@@ -1603,6 +1606,9 @@ int stop_topology_update(void)
 {
        int rc = 0;
 
+       if (!topology_updates_enabled)
+               return 0;
+
        if (prrn_enabled) {
                prrn_enabled = 0;
 #ifdef CONFIG_SMP
@@ -1648,11 +1654,13 @@ static ssize_t topology_write(struct file *file, const 
char __user *buf,
 
        kbuf[read_len] = '\0';
 
-       if (!strncmp(kbuf, "on", 2))
+       if (!strncmp(kbuf, "on", 2)) {
+               topology_updates_enabled = true;
                start_topology_update();
-       else if (!strncmp(kbuf, "off", 3))
+       } else if (!strncmp(kbuf, "off", 3)) {
                stop_topology_update();
-       else
+               topology_updates_enabled = false;
+       } else
                return -EINVAL;
 
        return count;
@@ -1667,9 +1675,7 @@ static const struct file_operations topology_ops = {
 
 static int topology_update_init(void)
 {
-       /* Do not poll for changes if disabled at boot */
-       if (topology_updates_enabled)
-               start_topology_update();
+       start_topology_update();
 
        if (!proc_create("powerpc/topology_updates", 0644, NULL, &topology_ops))
                return -ENOMEM;
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index b5226a009973..2996a1d0a410 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -47,7 +47,7 @@ export REALMODE_CFLAGS
 export BITS
 
 ifdef CONFIG_X86_NEED_RELOCS
-        LDFLAGS_vmlinux := --emit-relocs
+        LDFLAGS_vmlinux := --emit-relocs --discard-none
 endif
 
 #
diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index cb13c0564ea7..9978ea4382bf 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -60,9 +60,8 @@
 } while (0)
 
 #define RELOAD_SEG(seg)                {               \
-       unsigned int pre = GET_SEG(seg);        \
+       unsigned int pre = (seg) | 3;           \
        unsigned int cur = get_user_seg(seg);   \
-       pre |= 3;                               \
        if (pre != cur)                         \
                set_user_seg(seg, pre);         \
 }
@@ -71,6 +70,7 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
                                   struct sigcontext_32 __user *sc)
 {
        unsigned int tmpflags, err = 0;
+       u16 gs, fs, es, ds;
        void __user *buf;
        u32 tmp;
 
@@ -78,16 +78,10 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
        current->restart_block.fn = do_no_restart_syscall;
 
        get_user_try {
-               /*
-                * Reload fs and gs if they have changed in the signal
-                * handler.  This does not handle long fs/gs base changes in
-                * the handler, but does not clobber them at least in the
-                * normal case.
-                */
-               RELOAD_SEG(gs);
-               RELOAD_SEG(fs);
-               RELOAD_SEG(ds);
-               RELOAD_SEG(es);
+               gs = GET_SEG(gs);
+               fs = GET_SEG(fs);
+               ds = GET_SEG(ds);
+               es = GET_SEG(es);
 
                COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx);
                COPY(dx); COPY(cx); COPY(ip); COPY(ax);
@@ -105,6 +99,17 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
                buf = compat_ptr(tmp);
        } get_user_catch(err);
 
+       /*
+        * Reload fs and gs if they have changed in the signal
+        * handler.  This does not handle long fs/gs base changes in
+        * the handler, but does not clobber them at least in the
+        * normal case.
+        */
+       RELOAD_SEG(gs);
+       RELOAD_SEG(fs);
+       RELOAD_SEG(ds);
+       RELOAD_SEG(es);
+
        err |= fpu__restore_sig(buf, 1);
 
        force_iret();
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index d9ad49ca3cbe..e348bee411e3 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -673,20 +673,50 @@ bool machine_check_poll(enum mcp_flags flags, mce_banks_t 
*b)
 
                barrier();
                m.status = mce_rdmsrl(msr_ops.status(i));
+
+               /* If this entry is not valid, ignore it */
                if (!(m.status & MCI_STATUS_VAL))
                        continue;
 
 
                /*
-                * Uncorrected or signalled events are handled by the exception
-                * handler when it is enabled, so don't process those here.
-                *
-                * TBD do the same check for MCI_STATUS_EN here?
+                * If we are logging everything (at CPU online) or this
+                * is a corrected error, then we must log it.
                 */
-               if (!(flags & MCP_UC) &&
-                   (m.status & (mca_cfg.ser ? MCI_STATUS_S : MCI_STATUS_UC)))
-                       continue;
+               if ((flags & MCP_UC) || !(m.status & MCI_STATUS_UC))
+                       goto log_it;
+
+               /*
+                * Newer Intel systems that support software error
+                * recovery need to make additional checks. Other
+                * CPUs should skip over uncorrected errors, but log
+                * everything else.
+                */
+               if (!mca_cfg.ser) {
+                       if (m.status & MCI_STATUS_UC)
+                               continue;
+                       goto log_it;
+               }
+
+               /* Log "not enabled" (speculative) errors */
+               if (!(m.status & MCI_STATUS_EN))
+                       goto log_it;
+
+               /*
+                * Log UCNA (SDM: 15.6.3 "UCR Error Classification")
+                * UC == 1 && PCC == 0 && S == 0
+                */
+               if (!(m.status & MCI_STATUS_PCC) && !(m.status & MCI_STATUS_S))
+                       goto log_it;
+
+               /*
+                * Skip anything else. Presumption is that our read of this
+                * bank is racing with a machine check. Leave the log alone
+                * for do_machine_check() to deal with it.
+                */
+               continue;
 
+log_it:
                error_seen = true;
 
                mce_read_aux(&m, i);
diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
index bcd1b82c86e8..005e9a77a664 100644
--- a/arch/x86/kernel/irq_64.c
+++ b/arch/x86/kernel/irq_64.c
@@ -25,9 +25,18 @@ int sysctl_panic_on_stackoverflow;
 /*
  * Probabilistic stack overflow check:
  *
- * Only check the stack in process context, because everything else
- * runs on the big interrupt stacks. Checking reliably is too expensive,
- * so we just check from interrupts.
+ * Regular device interrupts can enter on the following stacks:
+ *
+ * - User stack
+ *
+ * - Kernel task stack
+ *
+ * - Interrupt stack if a device driver reenables interrupts
+ *   which should only happen in really old drivers.
+ *
+ * - Debug IST stack
+ *
+ * All other contexts are invalid.
  */
 static inline void stack_overflow_check(struct pt_regs *regs)
 {
@@ -52,8 +61,8 @@ static inline void stack_overflow_check(struct pt_regs *regs)
                return;
 
        oist = this_cpu_ptr(&orig_ist);
-       estack_top = (u64)oist->ist[0] - EXCEPTION_STKSZ + STACK_TOP_MARGIN;
-       estack_bottom = (u64)oist->ist[N_EXCEPTION_STACKS - 1];
+       estack_bottom = (u64)oist->ist[DEBUG_STACK];
+       estack_top = estack_bottom - DEBUG_STKSZ + STACK_TOP_MARGIN;
        if (regs->sp >= estack_top && regs->sp <= estack_bottom)
                return;
 
diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index b1a5d252d482..ca010dfb9682 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -129,16 +129,6 @@ static int restore_sigcontext(struct pt_regs *regs,
                COPY_SEG_CPL3(cs);
                COPY_SEG_CPL3(ss);
 
-#ifdef CONFIG_X86_64
-               /*
-                * Fix up SS if needed for the benefit of old DOSEMU and
-                * CRIU.
-                */
-               if (unlikely(!(uc_flags & UC_STRICT_RESTORE_SS) &&
-                            user_64bit_mode(regs)))
-                       force_valid_ss(regs);
-#endif
-
                get_user_ex(tmpflags, &sc->flags);
                regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & 
FIX_EFLAGS);
                regs->orig_ax = -1;             /* disable syscall checks */
@@ -147,6 +137,15 @@ static int restore_sigcontext(struct pt_regs *regs,
                buf = (void __user *)buf_val;
        } get_user_catch(err);
 
+#ifdef CONFIG_X86_64
+       /*
+        * Fix up SS if needed for the benefit of old DOSEMU and
+        * CRIU.
+        */
+       if (unlikely(!(uc_flags & UC_STRICT_RESTORE_SS) && 
user_64bit_mode(regs)))
+               force_valid_ss(regs);
+#endif
+
        err |= fpu__restore_sig(buf, IS_ENABLED(CONFIG_X86_32));
 
        force_iret();
@@ -458,6 +457,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
 {
        struct rt_sigframe __user *frame;
        void __user *fp = NULL;
+       unsigned long uc_flags;
        int err = 0;
 
        frame = get_sigframe(&ksig->ka, regs, sizeof(struct rt_sigframe), &fp);
@@ -470,9 +470,11 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
                        return -EFAULT;
        }
 
+       uc_flags = frame_uc_flags(regs);
+
        put_user_try {
                /* Create the ucontext.  */
-               put_user_ex(frame_uc_flags(regs), &frame->uc.uc_flags);
+               put_user_ex(uc_flags, &frame->uc.uc_flags);
                put_user_ex(0, &frame->uc.uc_link);
                save_altstack_ex(&frame->uc.uc_stack, regs->sp);
 
@@ -538,6 +540,7 @@ static int x32_setup_rt_frame(struct ksignal *ksig,
 {
 #ifdef CONFIG_X86_X32_ABI
        struct rt_sigframe_x32 __user *frame;
+       unsigned long uc_flags;
        void __user *restorer;
        int err = 0;
        void __user *fpstate = NULL;
@@ -552,9 +555,11 @@ static int x32_setup_rt_frame(struct ksignal *ksig,
                        return -EFAULT;
        }
 
+       uc_flags = frame_uc_flags(regs);
+
        put_user_try {
                /* Create the ucontext.  */
-               put_user_ex(frame_uc_flags(regs), &frame->uc.uc_flags);
+               put_user_ex(uc_flags, &frame->uc.uc_flags);
                put_user_ex(0, &frame->uc.uc_link);
                compat_save_altstack_ex(&frame->uc.uc_stack, regs->sp);
                put_user_ex(0, &frame->uc.uc__pad0);
diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index 55f04875293f..51b772f9d886 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -111,11 +111,11 @@ SECTIONS
                *(.text.__x86.indirect_thunk)
                __indirect_thunk_end = .;
 #endif
-
-               /* End of text section */
-               _etext = .;
        } :text = 0x9090
 
+       /* End of text section */
+       _etext = .;
+
        NOTES :text :note
 
        EXCEPTION_TABLE(16) :text = 0x9090
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 9338136a6a23..f7a7b98b3271 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1518,7 +1518,11 @@ static void avic_vcpu_load(struct kvm_vcpu *vcpu, int 
cpu)
        if (!kvm_vcpu_apicv_active(vcpu))
                return;
 
-       if (WARN_ON(h_physical_id >= AVIC_MAX_PHYSICAL_ID_COUNT))
+       /*
+        * Since the host physical APIC id is 8 bits,
+        * we can support host APIC ID upto 255.
+        */
+       if (WARN_ON(h_physical_id > 
AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK))
                return;
 
        entry = READ_ONCE(*(svm->avic_physical_id_cache));
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 1f32c4e32a00..72efecc4288b 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1109,7 +1109,7 @@ static int set_efer(struct kvm_vcpu *vcpu, struct 
msr_data *msr_info)
        u64 efer = msr_info->data;
 
        if (efer & efer_reserved_bits)
-               return false;
+               return 1;
 
        if (!msr_info->host_initiated) {
                if (!__kvm_valid_efer(vcpu, efer))
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 5c419b8f99a0..c140198d9fa5 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -430,8 +430,6 @@ static noinline int vmalloc_fault(unsigned long address)
        if (!(address >= VMALLOC_START && address < VMALLOC_END))
                return -1;
 
-       WARN_ON_ONCE(in_nmi());
-
        /*
         * Copy kernel mappings over when needed. This can also
         * happen within a race in page table update. In the later
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 98517216879d..a2714890fe43 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1383,6 +1383,10 @@ static int __device_suspend(struct device *dev, 
pm_message_t state, bool async)
        if (dev->power.syscore)
                goto Complete;
 
+       /* Avoid direct_complete to let wakeup_path propagate. */
+       if (device_may_wakeup(dev) || dev->power.wakeup_path)
+               dev->power.direct_complete = false;
+
        if (dev->power.direct_complete) {
                if (pm_runtime_status_suspended(dev)) {
                        pm_runtime_disable(dev);
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 8c0017d48571..800ced0a5a24 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -75,7 +75,7 @@ struct ports_driver_data {
        /* All the console devices handled by this driver */
        struct list_head consoles;
 };
-static struct ports_driver_data pdrvdata;
+static struct ports_driver_data pdrvdata = { .next_vtermno = 1};
 
 static DEFINE_SPINLOCK(pdrvdata_lock);
 static DECLARE_COMPLETION(early_console_added);
@@ -1425,6 +1425,7 @@ static int add_port(struct ports_device *portdev, u32 id)
        port->async_queue = NULL;
 
        port->cons.ws.ws_row = port->cons.ws.ws_col = 0;
+       port->cons.vtermno = 0;
 
        port->host_connected = port->guest_connected = false;
        port->stats = (struct port_stats) { 0 };
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index a38a23f0b3f4..e917521a3ef9 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1065,6 +1065,7 @@ static struct cpufreq_policy 
*cpufreq_policy_alloc(unsigned int cpu)
                                   cpufreq_global_kobject, "policy%u", cpu);
        if (ret) {
                pr_err("%s: failed to init policy->kobj: %d\n", __func__, ret);
+               kobject_put(&policy->kobj);
                goto err_free_real_cpus;
        }
 
diff --git a/drivers/cpufreq/cpufreq_governor.c 
b/drivers/cpufreq/cpufreq_governor.c
index 38d1a8216084..32c9524a6ec5 100644
--- a/drivers/cpufreq/cpufreq_governor.c
+++ b/drivers/cpufreq/cpufreq_governor.c
@@ -449,6 +449,8 @@ int cpufreq_dbs_governor_init(struct cpufreq_policy *policy)
        /* Failure, so roll back. */
        pr_err("initialization failed (dbs_data kobject init error %d)\n", ret);
 
+       kobject_put(&dbs_data->attr_set.kobj);
+
        policy->governor_data = NULL;
 
        if (!have_governor_per_policy())
diff --git a/drivers/cpufreq/pasemi-cpufreq.c b/drivers/cpufreq/pasemi-cpufreq.c
index 35dd4d7ffee0..58c933f48300 100644
--- a/drivers/cpufreq/pasemi-cpufreq.c
+++ b/drivers/cpufreq/pasemi-cpufreq.c
@@ -146,6 +146,7 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy 
*policy)
 
        cpu = of_get_cpu_node(policy->cpu, NULL);
 
+       of_node_put(cpu);
        if (!cpu)
                goto out;
 
diff --git a/drivers/cpufreq/pmac32-cpufreq.c b/drivers/cpufreq/pmac32-cpufreq.c
index ff44016ea031..641f8021855a 100644
--- a/drivers/cpufreq/pmac32-cpufreq.c
+++ b/drivers/cpufreq/pmac32-cpufreq.c
@@ -551,6 +551,7 @@ static int pmac_cpufreq_init_7447A(struct device_node 
*cpunode)
        volt_gpio_np = of_find_node_by_name(NULL, "cpu-vcore-select");
        if (volt_gpio_np)
                voltage_gpio = read_gpio(volt_gpio_np);
+       of_node_put(volt_gpio_np);
        if (!voltage_gpio){
                pr_err("missing cpu-vcore-select gpio\n");
                return 1;
@@ -587,6 +588,7 @@ static int pmac_cpufreq_init_750FX(struct device_node 
*cpunode)
        if (volt_gpio_np)
                voltage_gpio = read_gpio(volt_gpio_np);
 
+       of_node_put(volt_gpio_np);
        pvr = mfspr(SPRN_PVR);
        has_cpu_l2lve = !((pvr & 0xf00) == 0x100);
 
diff --git a/drivers/cpufreq/ppc_cbe_cpufreq.c 
b/drivers/cpufreq/ppc_cbe_cpufreq.c
index 5a4c5a639f61..2eaeebcc93af 100644
--- a/drivers/cpufreq/ppc_cbe_cpufreq.c
+++ b/drivers/cpufreq/ppc_cbe_cpufreq.c
@@ -86,6 +86,7 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy)
        if (!cbe_get_cpu_pmd_regs(policy->cpu) ||
            !cbe_get_cpu_mic_tm_regs(policy->cpu)) {
                pr_info("invalid CBE regs pointers for cpufreq\n");
+               of_node_put(cpu);
                return -EINVAL;
        }
 
diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c 
b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
index 0de2f62d51ff..ec16ec2e284d 100644
--- a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
+++ b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
@@ -250,7 +250,10 @@ static int sun4i_hash(struct ahash_request *areq)
                }
        } else {
                /* Since we have the flag final, we can go up to modulo 4 */
-               end = ((areq->nbytes + op->len) / 4) * 4 - op->len;
+               if (areq->nbytes < 4)
+                       end = 0;
+               else
+                       end = ((areq->nbytes + op->len) / 4) * 4 - op->len;
        }
 
        /* TODO if SGlen % 4 and op->len == 0 then DMA */
diff --git a/drivers/crypto/vmx/aesp8-ppc.pl b/drivers/crypto/vmx/aesp8-ppc.pl
index d9281a28818d..930a3f1e3ec0 100644
--- a/drivers/crypto/vmx/aesp8-ppc.pl
+++ b/drivers/crypto/vmx/aesp8-ppc.pl
@@ -1318,7 +1318,7 @@ Loop_ctr32_enc:
        addi            $idx,$idx,16
        bdnz            Loop_ctr32_enc
 
-       vadduwm         $ivec,$ivec,$one
+       vadduqm         $ivec,$ivec,$one
         vmr            $dat,$inptail
         lvx            $inptail,0,$inp
         addi           $inp,$inp,16
diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
index b222dd7afe8e..12d904829324 100644
--- a/drivers/dma/at_xdmac.c
+++ b/drivers/dma/at_xdmac.c
@@ -1608,7 +1608,11 @@ static void at_xdmac_tasklet(unsigned long data)
                                        struct at_xdmac_desc,
                                        xfer_node);
                dev_vdbg(chan2dev(&atchan->chan), "%s: desc 0x%p\n", __func__, 
desc);
-               BUG_ON(!desc->active_xfer);
+               if (!desc->active_xfer) {
+                       dev_err(chan2dev(&atchan->chan), "Xfer not active: 
exiting");
+                       spin_unlock_bh(&atchan->lock);
+                       return;
+               }
 
                txd = &desc->tx_dma_desc;
 
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 6d7e3cd4aba4..57b375d0de29 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -1020,6 +1020,7 @@ static void _stop(struct pl330_thread *thrd)
 {
        void __iomem *regs = thrd->dmac->base;
        u8 insn[6] = {0, 0, 0, 0, 0, 0};
+       u32 inten = readl(regs + INTEN);
 
        if (_state(thrd) == PL330_STATE_FAULT_COMPLETING)
                UNTIL(thrd, PL330_STATE_FAULTING | PL330_STATE_KILLING);
@@ -1032,10 +1033,13 @@ static void _stop(struct pl330_thread *thrd)
 
        _emit_KILL(0, insn);
 
-       /* Stop generating interrupts for SEV */
-       writel(readl(regs + INTEN) & ~(1 << thrd->ev), regs + INTEN);
-
        _execute_DBGINSN(thrd, insn, is_manager(thrd));
+
+       /* clear the event */
+       if (inten & (1 << thrd->ev))
+               writel(1 << thrd->ev, regs + INTCLR);
+       /* Stop generating interrupts for SEV */
+       writel(inten & ~(1 << thrd->ev), regs + INTEN);
 }
 
 /* Start doing req 'idx' of thread 'thrd' */
diff --git a/drivers/dma/tegra210-adma.c b/drivers/dma/tegra210-adma.c
index b10cbaa82ff5..e9e46a520745 100644
--- a/drivers/dma/tegra210-adma.c
+++ b/drivers/dma/tegra210-adma.c
@@ -22,7 +22,6 @@
 #include <linux/of_device.h>
 #include <linux/of_dma.h>
 #include <linux/of_irq.h>
-#include <linux/pm_clock.h>
 #include <linux/pm_runtime.h>
 #include <linux/slab.h>
 
@@ -141,6 +140,7 @@ struct tegra_adma {
        struct dma_device               dma_dev;
        struct device                   *dev;
        void __iomem                    *base_addr;
+       struct clk                      *ahub_clk;
        unsigned int                    nr_channels;
        unsigned long                   rx_requests_reserved;
        unsigned long                   tx_requests_reserved;
@@ -637,8 +637,9 @@ static int tegra_adma_runtime_suspend(struct device *dev)
        struct tegra_adma *tdma = dev_get_drvdata(dev);
 
        tdma->global_cmd = tdma_read(tdma, ADMA_GLOBAL_CMD);
+       clk_disable_unprepare(tdma->ahub_clk);
 
-       return pm_clk_suspend(dev);
+       return 0;
 }
 
 static int tegra_adma_runtime_resume(struct device *dev)
@@ -646,10 +647,11 @@ static int tegra_adma_runtime_resume(struct device *dev)
        struct tegra_adma *tdma = dev_get_drvdata(dev);
        int ret;
 
-       ret = pm_clk_resume(dev);
-       if (ret)
+       ret = clk_prepare_enable(tdma->ahub_clk);
+       if (ret) {
+               dev_err(dev, "ahub clk_enable failed: %d\n", ret);
                return ret;
-
+       }
        tdma_write(tdma, ADMA_GLOBAL_CMD, tdma->global_cmd);
 
        return 0;
@@ -692,13 +694,11 @@ static int tegra_adma_probe(struct platform_device *pdev)
        if (IS_ERR(tdma->base_addr))
                return PTR_ERR(tdma->base_addr);
 
-       ret = pm_clk_create(&pdev->dev);
-       if (ret)
-               return ret;
-
-       ret = of_pm_clk_add_clk(&pdev->dev, "d_audio");
-       if (ret)
-               goto clk_destroy;
+       tdma->ahub_clk = devm_clk_get(&pdev->dev, "d_audio");
+       if (IS_ERR(tdma->ahub_clk)) {
+               dev_err(&pdev->dev, "Error: Missing ahub controller clock\n");
+               return PTR_ERR(tdma->ahub_clk);
+       }
 
        pm_runtime_enable(&pdev->dev);
 
@@ -775,8 +775,6 @@ static int tegra_adma_probe(struct platform_device *pdev)
        pm_runtime_put_sync(&pdev->dev);
 rpm_disable:
        pm_runtime_disable(&pdev->dev);
-clk_destroy:
-       pm_clk_destroy(&pdev->dev);
 
        return ret;
 }
@@ -786,6 +784,7 @@ static int tegra_adma_remove(struct platform_device *pdev)
        struct tegra_adma *tdma = platform_get_drvdata(pdev);
        int i;
 
+       of_dma_controller_free(pdev->dev.of_node);
        dma_async_device_unregister(&tdma->dma_dev);
 
        for (i = 0; i < tdma->nr_channels; ++i)
@@ -793,7 +792,6 @@ static int tegra_adma_remove(struct platform_device *pdev)
 
        pm_runtime_put_sync(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
-       pm_clk_destroy(&pdev->dev);
 
        return 0;
 }
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 56e6c4c7c60d..4c0b6df8b5dd 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -1684,6 +1684,16 @@ static int arizona_extcon_remove(struct platform_device 
*pdev)
        struct arizona_extcon_info *info = platform_get_drvdata(pdev);
        struct arizona *arizona = info->arizona;
        int jack_irq_rise, jack_irq_fall;
+       bool change;
+
+       regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1,
+                                ARIZONA_MICD_ENA, 0,
+                                &change);
+
+       if (change) {
+               regulator_disable(info->micvdd);
+               pm_runtime_put(info->dev);
+       }
 
        gpiod_put(info->micd_pol_gpio);
 
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index c37b7b5f1dd3..921f7f690ae9 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -515,6 +515,7 @@ ssize_t drm_read(struct file *filp, char __user *buffer,
                                file_priv->event_space -= length;
                                list_add(&e->link, &file_priv->event_list);
                                spin_unlock_irq(&dev->event_lock);
+                               wake_up_interruptible(&file_priv->event_wait);
                                break;
                        }
 
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 70597854397f..ceb4df96e0d5 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -200,13 +200,14 @@ static unsigned hid_lookup_collection(struct hid_parser 
*parser, unsigned type)
  * Add a usage to the temporary parser table.
  */
 
-static int hid_add_usage(struct hid_parser *parser, unsigned usage)
+static int hid_add_usage(struct hid_parser *parser, unsigned usage, u8 size)
 {
        if (parser->local.usage_index >= HID_MAX_USAGES) {
                hid_err(parser->device, "usage index exceeded\n");
                return -1;
        }
        parser->local.usage[parser->local.usage_index] = usage;
+       parser->local.usage_size[parser->local.usage_index] = size;
        parser->local.collection_index[parser->local.usage_index] =
                parser->collection_stack_ptr ?
                parser->collection_stack[parser->collection_stack_ptr - 1] : 0;
@@ -463,10 +464,7 @@ static int hid_parser_local(struct hid_parser *parser, 
struct hid_item *item)
                        return 0;
                }
 
-               if (item->size <= 2)
-                       data = (parser->global.usage_page << 16) + data;
-
-               return hid_add_usage(parser, data);
+               return hid_add_usage(parser, data, item->size);
 
        case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM:
 
@@ -475,9 +473,6 @@ static int hid_parser_local(struct hid_parser *parser, 
struct hid_item *item)
                        return 0;
                }
 
-               if (item->size <= 2)
-                       data = (parser->global.usage_page << 16) + data;
-
                parser->local.usage_minimum = data;
                return 0;
 
@@ -488,9 +483,6 @@ static int hid_parser_local(struct hid_parser *parser, 
struct hid_item *item)
                        return 0;
                }
 
-               if (item->size <= 2)
-                       data = (parser->global.usage_page << 16) + data;
-
                count = data - parser->local.usage_minimum;
                if (count + parser->local.usage_index >= HID_MAX_USAGES) {
                        /*
@@ -510,7 +502,7 @@ static int hid_parser_local(struct hid_parser *parser, 
struct hid_item *item)
                }
 
                for (n = parser->local.usage_minimum; n <= data; n++)
-                       if (hid_add_usage(parser, n)) {
+                       if (hid_add_usage(parser, n, item->size)) {
                                dbg_hid("hid_add_usage failed\n");
                                return -1;
                        }
@@ -524,6 +516,22 @@ static int hid_parser_local(struct hid_parser *parser, 
struct hid_item *item)
        return 0;
 }
 
+/*
+ * Concatenate Usage Pages into Usages where relevant:
+ * As per specification, 6.2.2.8: "When the parser encounters a main item it
+ * concatenates the last declared Usage Page with a Usage to form a complete
+ * usage value."
+ */
+
+static void hid_concatenate_usage_page(struct hid_parser *parser)
+{
+       int i;
+
+       for (i = 0; i < parser->local.usage_index; i++)
+               if (parser->local.usage_size[i] <= 2)
+                       parser->local.usage[i] += parser->global.usage_page << 
16;
+}
+
 /*
  * Process a main item.
  */
@@ -533,6 +541,8 @@ static int hid_parser_main(struct hid_parser *parser, 
struct hid_item *item)
        __u32 data;
        int ret;
 
+       hid_concatenate_usage_page(parser);
+
        data = item_udata(item);
 
        switch (item->tag) {
@@ -746,6 +756,8 @@ static int hid_scan_main(struct hid_parser *parser, struct 
hid_item *item)
        __u32 data;
        int i;
 
+       hid_concatenate_usage_page(parser);
+
        data = item_udata(item);
 
        switch (item->tag) {
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index 3198faf5cff4..38d9deb03d16 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -449,13 +449,16 @@ static int hidpp_root_get_feature(struct hidpp_device 
*hidpp, u16 feature,
 
 static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp)
 {
+       const u8 ping_byte = 0x5a;
+       u8 ping_data[3] = { 0, 0, ping_byte };
        struct hidpp_report response;
        int ret;
 
-       ret = hidpp_send_fap_command_sync(hidpp,
+       ret = hidpp_send_rap_command_sync(hidpp,
+                       REPORT_ID_HIDPP_SHORT,
                        HIDPP_PAGE_ROOT_IDX,
                        CMD_ROOT_GET_PROTOCOL_VERSION,
-                       NULL, 0, &response);
+                       ping_data, sizeof(ping_data), &response);
 
        if (ret == HIDPP_ERROR_INVALID_SUBID) {
                hidpp->protocol_major = 1;
@@ -475,8 +478,14 @@ static int hidpp_root_get_protocol_version(struct 
hidpp_device *hidpp)
        if (ret)
                return ret;
 
-       hidpp->protocol_major = response.fap.params[0];
-       hidpp->protocol_minor = response.fap.params[1];
+       if (response.rap.params[2] != ping_byte) {
+               hid_err(hidpp->hid_dev, "%s: ping mismatch 0x%02x != 0x%02x\n",
+                       __func__, response.rap.params[2], ping_byte);
+               return -EPROTO;
+       }
+
+       hidpp->protocol_major = response.rap.params[0];
+       hidpp->protocol_minor = response.rap.params[1];
 
        return ret;
 }
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c
index facd05cda26d..e8c089886427 100644
--- a/drivers/hwmon/f71805f.c
+++ b/drivers/hwmon/f71805f.c
@@ -96,17 +96,23 @@ superio_select(int base, int ld)
        outb(ld, base + 1);
 }
 
-static inline void
+static inline int
 superio_enter(int base)
 {
+       if (!request_muxed_region(base, 2, DRVNAME))
+               return -EBUSY;
+
        outb(0x87, base);
        outb(0x87, base);
+
+       return 0;
 }
 
 static inline void
 superio_exit(int base)
 {
        outb(0xaa, base);
+       release_region(base, 2);
 }
 
 /*
@@ -1561,7 +1567,7 @@ static int __init f71805f_device_add(unsigned short 
address,
 static int __init f71805f_find(int sioaddr, unsigned short *address,
                               struct f71805f_sio_data *sio_data)
 {
-       int err = -ENODEV;
+       int err;
        u16 devid;
 
        static const char * const names[] = {
@@ -1569,8 +1575,11 @@ static int __init f71805f_find(int sioaddr, unsigned 
short *address,
                "F71872F/FG or F71806F/FG",
        };
 
-       superio_enter(sioaddr);
+       err = superio_enter(sioaddr);
+       if (err)
+               return err;
 
+       err = -ENODEV;
        devid = superio_inw(sioaddr, SIO_REG_MANID);
        if (devid != SIO_FINTEK_ID)
                goto exit;
diff --git a/drivers/hwmon/pc87427.c b/drivers/hwmon/pc87427.c
index cb9fdd37bd0d..2b5b8c3de8fc 100644
--- a/drivers/hwmon/pc87427.c
+++ b/drivers/hwmon/pc87427.c
@@ -106,6 +106,13 @@ static const char *logdev_str[2] = { DRVNAME " FMC", 
DRVNAME " HMC" };
 #define LD_IN          1
 #define LD_TEMP                1
 
+static inline int superio_enter(int sioaddr)
+{
+       if (!request_muxed_region(sioaddr, 2, DRVNAME))
+               return -EBUSY;
+       return 0;
+}
+
 static inline void superio_outb(int sioaddr, int reg, int val)
 {
        outb(reg, sioaddr);
@@ -122,6 +129,7 @@ static inline void superio_exit(int sioaddr)
 {
        outb(0x02, sioaddr);
        outb(0x02, sioaddr + 1);
+       release_region(sioaddr, 2);
 }
 
 /*
@@ -1220,7 +1228,11 @@ static int __init pc87427_find(int sioaddr, struct 
pc87427_sio_data *sio_data)
 {
        u16 val;
        u8 cfg, cfg_b;
-       int i, err = 0;
+       int i, err;
+
+       err = superio_enter(sioaddr);
+       if (err)
+               return err;
 
        /* Identify device */
        val = force_id ? force_id : superio_inb(sioaddr, SIOREG_DEVID);
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
index 6bd200756560..cbdb5c4991ae 100644
--- a/drivers/hwmon/smsc47b397.c
+++ b/drivers/hwmon/smsc47b397.c
@@ -72,14 +72,19 @@ static inline void superio_select(int ld)
        superio_outb(0x07, ld);
 }
 
-static inline void superio_enter(void)
+static inline int superio_enter(void)
 {
+       if (!request_muxed_region(REG, 2, DRVNAME))
+               return -EBUSY;
+
        outb(0x55, REG);
+       return 0;
 }
 
 static inline void superio_exit(void)
 {
        outb(0xAA, REG);
+       release_region(REG, 2);
 }
 
 #define SUPERIO_REG_DEVID      0x20
@@ -300,8 +305,12 @@ static int __init smsc47b397_find(void)
        u8 id, rev;
        char *name;
        unsigned short addr;
+       int err;
+
+       err = superio_enter();
+       if (err)
+               return err;
 
-       superio_enter();
        id = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID);
 
        switch (id) {
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index 5d323186d2c1..d24df0c50bea 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -73,16 +73,21 @@ superio_inb(int reg)
 /* logical device for fans is 0x0A */
 #define superio_select() superio_outb(0x07, 0x0A)
 
-static inline void
+static inline int
 superio_enter(void)
 {
+       if (!request_muxed_region(REG, 2, DRVNAME))
+               return -EBUSY;
+
        outb(0x55, REG);
+       return 0;
 }
 
 static inline void
 superio_exit(void)
 {
        outb(0xAA, REG);
+       release_region(REG, 2);
 }
 
 #define SUPERIO_REG_ACT                0x30
@@ -531,8 +536,12 @@ static int __init smsc47m1_find(struct smsc47m1_sio_data 
*sio_data)
 {
        u8 val;
        unsigned short addr;
+       int err;
+
+       err = superio_enter();
+       if (err)
+               return err;
 
-       superio_enter();
        val = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID);
 
        /*
@@ -608,13 +617,14 @@ static int __init smsc47m1_find(struct smsc47m1_sio_data 
*sio_data)
 static void smsc47m1_restore(const struct smsc47m1_sio_data *sio_data)
 {
        if ((sio_data->activate & 0x01) == 0) {
-               superio_enter();
-               superio_select();
-
-               pr_info("Disabling device\n");
-               superio_outb(SUPERIO_REG_ACT, sio_data->activate);
-
-               superio_exit();
+               if (!superio_enter()) {
+                       superio_select();
+                       pr_info("Disabling device\n");
+                       superio_outb(SUPERIO_REG_ACT, sio_data->activate);
+                       superio_exit();
+               } else {
+                       pr_warn("Failed to disable device\n");
+               }
        }
 }
 
diff --git a/drivers/hwmon/vt1211.c b/drivers/hwmon/vt1211.c
index 3a6bfa51cb94..95d5e8ec8b7f 100644
--- a/drivers/hwmon/vt1211.c
+++ b/drivers/hwmon/vt1211.c
@@ -226,15 +226,21 @@ static inline void superio_select(int sio_cip, int ldn)
        outb(ldn, sio_cip + 1);
 }
 
-static inline void superio_enter(int sio_cip)
+static inline int superio_enter(int sio_cip)
 {
+       if (!request_muxed_region(sio_cip, 2, DRVNAME))
+               return -EBUSY;
+
        outb(0x87, sio_cip);
        outb(0x87, sio_cip);
+
+       return 0;
 }
 
 static inline void superio_exit(int sio_cip)
 {
        outb(0xaa, sio_cip);
+       release_region(sio_cip, 2);
 }
 
 /* ---------------------------------------------------------------------
@@ -1282,11 +1288,14 @@ static int __init vt1211_device_add(unsigned short 
address)
 
 static int __init vt1211_find(int sio_cip, unsigned short *address)
 {
-       int err = -ENODEV;
+       int err;
        int devid;
 
-       superio_enter(sio_cip);
+       err = superio_enter(sio_cip);
+       if (err)
+               return err;
 
+       err = -ENODEV;
        devid = force_id ? force_id : superio_inb(sio_cip, SIO_VT1211_DEVID);
        if (devid != SIO_VT1211_ID)
                goto EXIT;
diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c
index a1d072ecb717..30f200ad6b97 100644
--- a/drivers/iio/adc/ad_sigma_delta.c
+++ b/drivers/iio/adc/ad_sigma_delta.c
@@ -62,7 +62,7 @@ int ad_sd_write_reg(struct ad_sigma_delta *sigma_delta, 
unsigned int reg,
        struct spi_transfer t = {
                .tx_buf         = data,
                .len            = size + 1,
-               .cs_change      = sigma_delta->bus_locked,
+               .cs_change      = sigma_delta->keep_cs_asserted,
        };
        struct spi_message m;
        int ret;
@@ -217,6 +217,7 @@ static int ad_sd_calibrate(struct ad_sigma_delta 
*sigma_delta,
 
        spi_bus_lock(sigma_delta->spi->master);
        sigma_delta->bus_locked = true;
+       sigma_delta->keep_cs_asserted = true;
        reinit_completion(&sigma_delta->completion);
 
        ret = ad_sigma_delta_set_mode(sigma_delta, mode);
@@ -234,9 +235,10 @@ static int ad_sd_calibrate(struct ad_sigma_delta 
*sigma_delta,
                ret = 0;
        }
 out:
+       sigma_delta->keep_cs_asserted = false;
+       ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_IDLE);
        sigma_delta->bus_locked = false;
        spi_bus_unlock(sigma_delta->spi->master);
-       ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_IDLE);
 
        return ret;
 }
@@ -288,6 +290,7 @@ int ad_sigma_delta_single_conversion(struct iio_dev 
*indio_dev,
 
        spi_bus_lock(sigma_delta->spi->master);
        sigma_delta->bus_locked = true;
+       sigma_delta->keep_cs_asserted = true;
        reinit_completion(&sigma_delta->completion);
 
        ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_SINGLE);
@@ -297,9 +300,6 @@ int ad_sigma_delta_single_conversion(struct iio_dev 
*indio_dev,
        ret = wait_for_completion_interruptible_timeout(
                        &sigma_delta->completion, HZ);
 
-       sigma_delta->bus_locked = false;
-       spi_bus_unlock(sigma_delta->spi->master);
-
        if (ret == 0)
                ret = -EIO;
        if (ret < 0)
@@ -315,7 +315,10 @@ int ad_sigma_delta_single_conversion(struct iio_dev 
*indio_dev,
                sigma_delta->irq_dis = true;
        }
 
+       sigma_delta->keep_cs_asserted = false;
        ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_IDLE);
+       sigma_delta->bus_locked = false;
+       spi_bus_unlock(sigma_delta->spi->master);
        mutex_unlock(&indio_dev->mlock);
 
        if (ret)
@@ -352,6 +355,8 @@ static int ad_sd_buffer_postenable(struct iio_dev 
*indio_dev)
 
        spi_bus_lock(sigma_delta->spi->master);
        sigma_delta->bus_locked = true;
+       sigma_delta->keep_cs_asserted = true;
+
        ret = ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_CONTINUOUS);
        if (ret)
                goto err_unlock;
@@ -380,6 +385,7 @@ static int ad_sd_buffer_postdisable(struct iio_dev 
*indio_dev)
                sigma_delta->irq_dis = true;
        }
 
+       sigma_delta->keep_cs_asserted = false;
        ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_IDLE);
 
        sigma_delta->bus_locked = false;
diff --git a/drivers/iio/common/ssp_sensors/ssp_iio.c 
b/drivers/iio/common/ssp_sensors/ssp_iio.c
index a3ae165f8d9f..16180e6321bd 100644
--- a/drivers/iio/common/ssp_sensors/ssp_iio.c
+++ b/drivers/iio/common/ssp_sensors/ssp_iio.c
@@ -80,7 +80,7 @@ int ssp_common_process_data(struct iio_dev *indio_dev, void 
*buf,
                            unsigned int len, int64_t timestamp)
 {
        __le32 time;
-       int64_t calculated_time;
+       int64_t calculated_time = 0;
        struct ssp_sensor_data *spd = iio_priv(indio_dev);
 
        if (indio_dev->scan_bytes == 0)
diff --git a/drivers/iio/magnetometer/hmc5843_i2c.c 
b/drivers/iio/magnetometer/hmc5843_i2c.c
index 3de7f4426ac4..86abba5827a2 100644
--- a/drivers/iio/magnetometer/hmc5843_i2c.c
+++ b/drivers/iio/magnetometer/hmc5843_i2c.c
@@ -58,8 +58,13 @@ static const struct regmap_config hmc5843_i2c_regmap_config 
= {
 static int hmc5843_i2c_probe(struct i2c_client *cli,
                             const struct i2c_device_id *id)
 {
+       struct regmap *regmap = devm_regmap_init_i2c(cli,
+                       &hmc5843_i2c_regmap_config);
+       if (IS_ERR(regmap))
+               return PTR_ERR(regmap);
+
        return hmc5843_common_probe(&cli->dev,
-                       devm_regmap_init_i2c(cli, &hmc5843_i2c_regmap_config),
+                       regmap,
                        id->driver_data, id->name);
 }
 
diff --git a/drivers/iio/magnetometer/hmc5843_spi.c 
b/drivers/iio/magnetometer/hmc5843_spi.c
index 535f03a70d63..79b2b707f90e 100644
--- a/drivers/iio/magnetometer/hmc5843_spi.c
+++ b/drivers/iio/magnetometer/hmc5843_spi.c
@@ -58,6 +58,7 @@ static const struct regmap_config hmc5843_spi_regmap_config = 
{
 static int hmc5843_spi_probe(struct spi_device *spi)
 {
        int ret;
+       struct regmap *regmap;
        const struct spi_device_id *id = spi_get_device_id(spi);
 
        spi->mode = SPI_MODE_3;
@@ -67,8 +68,12 @@ static int hmc5843_spi_probe(struct spi_device *spi)
        if (ret)
                return ret;
 
+       regmap = devm_regmap_init_spi(spi, &hmc5843_spi_regmap_config);
+       if (IS_ERR(regmap))
+               return PTR_ERR(regmap);
+
        return hmc5843_common_probe(&spi->dev,
-                       devm_regmap_init_spi(spi, &hmc5843_spi_regmap_config),
+                       regmap,
                        id->driver_data, id->name);
 }
 
diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index a2322b2dbd82..e5752352e0fb 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -455,6 +455,8 @@ static struct sk_buff *get_skb(struct sk_buff *skb, int 
len, gfp_t gfp)
                skb_reset_transport_header(skb);
        } else {
                skb = alloc_skb(len, gfp);
+               if (!skb)
+                       return NULL;
        }
        t4_set_arp_err_handler(skb, NULL, NULL);
        return skb;
diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c
index dd344ee9e62b..ebacd21714ef 100644
--- a/drivers/md/bcache/alloc.c
+++ b/drivers/md/bcache/alloc.c
@@ -322,10 +322,11 @@ static int bch_allocator_thread(void *arg)
                 * possibly issue discards to them, then we add the bucket to
                 * the free list:
                 */
-               while (!fifo_empty(&ca->free_inc)) {
+               while (1) {
                        long bucket;
 
-                       fifo_pop(&ca->free_inc, bucket);
+                       if (!fifo_pop(&ca->free_inc, bucket))
+                               break;
 
                        if (ca->discard) {
                                mutex_unlock(&ca->set->bucket_lock);
diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
index c76a0176b5c6..6ee5370eb916 100644
--- a/drivers/md/bcache/journal.c
+++ b/drivers/md/bcache/journal.c
@@ -309,6 +309,18 @@ void bch_journal_mark(struct cache_set *c, struct 
list_head *list)
        }
 }
 
+bool is_discard_enabled(struct cache_set *s)
+{
+       struct cache *ca;
+       unsigned int i;
+
+       for_each_cache(ca, s, i)
+               if (ca->discard)
+                       return true;
+
+       return false;
+}
+
 int bch_journal_replay(struct cache_set *s, struct list_head *list)
 {
        int ret = 0, keys = 0, entries = 0;
@@ -322,9 +334,17 @@ int bch_journal_replay(struct cache_set *s, struct 
list_head *list)
        list_for_each_entry(i, list, list) {
                BUG_ON(i->pin && atomic_read(i->pin) != 1);
 
-               cache_set_err_on(n != i->j.seq, s,
-"bcache: journal entries %llu-%llu missing! (replaying %llu-%llu)",
-                                n, i->j.seq - 1, start, end);
+               if (n != i->j.seq) {
+                       if (n == start && is_discard_enabled(s))
+                               pr_info("bcache: journal entries %llu-%llu may 
be discarded! (replaying %llu-%llu)",
+                                       n, i->j.seq - 1, start, end);
+                       else {
+                               pr_err("bcache: journal entries %llu-%llu 
missing! (replaying %llu-%llu)",
+                                       n, i->j.seq - 1, start, end);
+                               ret = -EIO;
+                               goto err;
+                       }
+               }
 
                for (k = i->j.start;
                     k < bset_bkey_last(&i->j);
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 362efc8dd16f..9f2588eaaf5f 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1561,7 +1561,7 @@ struct cache_set *bch_cache_set_alloc(struct cache_sb *sb)
        return NULL;
 }
 
-static void run_cache_set(struct cache_set *c)
+static int run_cache_set(struct cache_set *c)
 {
        const char *err = "cannot allocate memory";
        struct cached_dev *dc, *t;
@@ -1653,7 +1653,9 @@ static void run_cache_set(struct cache_set *c)
                if (j->version < BCACHE_JSET_VERSION_UUID)
                        __uuid_write(c);
 
-               bch_journal_replay(c, &journal);
+               err = "bcache: replay journal failed";
+               if (bch_journal_replay(c, &journal))
+                       goto err;
        } else {
                pr_notice("invalidating existing data");
 
@@ -1721,11 +1723,13 @@ static void run_cache_set(struct cache_set *c)
        flash_devs_run(c);
 
        set_bit(CACHE_SET_RUNNING, &c->flags);
-       return;
+       return 0;
 err:
        closure_sync(&cl);
        /* XXX: test this, it's broken */
        bch_cache_set_error(c, "%s", err);
+
+       return -EIO;
 }
 
 static bool can_attach_cache(struct cache *ca, struct cache_set *c)
@@ -1789,8 +1793,11 @@ static const char *register_cache_set(struct cache *ca)
        ca->set->cache[ca->sb.nr_this_dev] = ca;
        c->cache_by_alloc[c->caches_loaded++] = ca;
 
-       if (c->caches_loaded == c->sb.nr_in_set)
-               run_cache_set(c);
+       if (c->caches_loaded == c->sb.nr_in_set) {
+               err = "failed to run cache set";
+               if (run_cache_set(c) < 0)
+                       goto err;
+       }
 
        return NULL;
 err:
diff --git a/drivers/media/dvb-frontends/m88ds3103.c 
b/drivers/media/dvb-frontends/m88ds3103.c
index 31f16105184c..59a4563c0466 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -309,6 +309,9 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
        u16 u16tmp;
        u32 tuner_frequency_khz, target_mclk;
        s32 s32tmp;
+       static const struct reg_sequence reset_buf[] = {
+               {0x07, 0x80}, {0x07, 0x00}
+       };
 
        dev_dbg(&client->dev,
                "delivery_system=%d modulation=%d frequency=%u symbol_rate=%d 
inversion=%d pilot=%d rolloff=%d\n",
@@ -321,11 +324,7 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
        }
 
        /* reset */
-       ret = regmap_write(dev->regmap, 0x07, 0x80);
-       if (ret)
-               goto err;
-
-       ret = regmap_write(dev->regmap, 0x07, 0x00);
+       ret = regmap_multi_reg_write(dev->regmap, reset_buf, 2);
        if (ret)
                goto err;
 
diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 1f999e9c0118..3554eea77e04 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1117,8 +1117,10 @@ static int ov2659_set_fmt(struct v4l2_subdev *sd,
                if (ov2659_formats[index].code == mf->code)
                        break;
 
-       if (index < 0)
-               return -EINVAL;
+       if (index < 0) {
+               index = 0;
+               mf->code = ov2659_formats[index].code;
+       }
 
        mf->colorspace = V4L2_COLORSPACE_SRGB;
        mf->code = ov2659_formats[index].code;
diff --git a/drivers/media/i2c/soc_camera/ov6650.c 
b/drivers/media/i2c/soc_camera/ov6650.c
index e21b7e1c2ee1..fc187c5aeb1e 100644
--- a/drivers/media/i2c/soc_camera/ov6650.c
+++ b/drivers/media/i2c/soc_camera/ov6650.c
@@ -840,9 +840,16 @@ static int ov6650_video_probe(struct i2c_client *client)
        u8              pidh, pidl, midh, midl;
        int             ret;
 
+       priv->clk = v4l2_clk_get(&client->dev, NULL);
+       if (IS_ERR(priv->clk)) {
+               ret = PTR_ERR(priv->clk);
+               dev_err(&client->dev, "v4l2_clk request err: %d\n", ret);
+               return ret;
+       }
+
        ret = ov6650_s_power(&priv->subdev, 1);
        if (ret < 0)
-               return ret;
+               goto eclkput;
 
        msleep(20);
 
@@ -879,6 +886,11 @@ static int ov6650_video_probe(struct i2c_client *client)
 
 done:
        ov6650_s_power(&priv->subdev, 0);
+       if (!ret)
+               return 0;
+eclkput:
+       v4l2_clk_put(priv->clk);
+
        return ret;
 }
 
@@ -1035,18 +1047,9 @@ static int ov6650_probe(struct i2c_client *client,
        priv->code        = MEDIA_BUS_FMT_YUYV8_2X8;
        priv->colorspace  = V4L2_COLORSPACE_JPEG;
 
-       priv->clk = v4l2_clk_get(&client->dev, NULL);
-       if (IS_ERR(priv->clk)) {
-               ret = PTR_ERR(priv->clk);
-               goto eclkget;
-       }
-
        ret = ov6650_video_probe(client);
-       if (ret) {
-               v4l2_clk_put(priv->clk);
-eclkget:
+       if (ret)
                v4l2_ctrl_handler_free(&priv->hdl);
-       }
 
        return ret;
 }
diff --git a/drivers/media/pci/saa7146/hexium_gemini.c 
b/drivers/media/pci/saa7146/hexium_gemini.c
index c889ec9f8a5a..f5fc8bcbd14b 100644
--- a/drivers/media/pci/saa7146/hexium_gemini.c
+++ b/drivers/media/pci/saa7146/hexium_gemini.c
@@ -270,9 +270,8 @@ static int hexium_attach(struct saa7146_dev *dev, struct 
saa7146_pci_extension_d
        /* enable i2c-port pins */
        saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26));
 
-       hexium->i2c_adapter = (struct i2c_adapter) {
-               .name = "hexium gemini",
-       };
+       strscpy(hexium->i2c_adapter.name, "hexium gemini",
+               sizeof(hexium->i2c_adapter.name));
        saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, 
SAA7146_I2C_BUS_BIT_RATE_480);
        if (i2c_add_adapter(&hexium->i2c_adapter) < 0) {
                DEB_S("cannot register i2c-device. skipping.\n");
diff --git a/drivers/media/pci/saa7146/hexium_orion.c 
b/drivers/media/pci/saa7146/hexium_orion.c
index c306a92e8909..dc07ca37ebd0 100644
--- a/drivers/media/pci/saa7146/hexium_orion.c
+++ b/drivers/media/pci/saa7146/hexium_orion.c
@@ -232,9 +232,8 @@ static int hexium_probe(struct saa7146_dev *dev)
        saa7146_write(dev, DD1_STREAM_B, 0x00000000);
        saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
 
-       hexium->i2c_adapter = (struct i2c_adapter) {
-               .name = "hexium orion",
-       };
+       strscpy(hexium->i2c_adapter.name, "hexium orion",
+               sizeof(hexium->i2c_adapter.name));
        saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, 
SAA7146_I2C_BUS_BIT_RATE_480);
        if (i2c_add_adapter(&hexium->i2c_adapter) < 0) {
                DEB_S("cannot register i2c-device. skipping.\n");
diff --git a/drivers/media/platform/coda/coda-bit.c 
b/drivers/media/platform/coda/coda-bit.c
index b6625047250d..717ee9a6a80e 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -1829,6 +1829,9 @@ static int coda_prepare_decode(struct coda_ctx *ctx)
        /* Clear decode success flag */
        coda_write(dev, 0, CODA_RET_DEC_PIC_SUCCESS);
 
+       /* Clear error return value */
+       coda_write(dev, 0, CODA_RET_DEC_PIC_ERR_MB);
+
        trace_coda_dec_pic_run(ctx, meta);
 
        coda_command_async(ctx, CODA_COMMAND_PIC_RUN);
diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c 
b/drivers/media/platform/vivid/vivid-vid-cap.c
index 25d4fd4f4c0b..a72982df4777 100644
--- a/drivers/media/platform/vivid/vivid-vid-cap.c
+++ b/drivers/media/platform/vivid/vivid-vid-cap.c
@@ -984,7 +984,7 @@ int vivid_vid_cap_s_selection(struct file *file, void *fh, 
struct v4l2_selection
                v4l2_rect_map_inside(&s->r, &dev->fmt_cap_rect);
                if (dev->bitmap_cap && (compose->width != s->r.width ||
                                        compose->height != s->r.height)) {
-                       kfree(dev->bitmap_cap);
+                       vfree(dev->bitmap_cap);
                        dev->bitmap_cap = NULL;
                }
                *compose = s->r;
diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index 642b89c66bcb..c1457cf46698 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -494,7 +494,8 @@ int fmc_send_cmd(struct fmdev *fmdev, u8 fm_op, u16 type, 
void *payload,
                return -EIO;
        }
        /* Send response data to caller */
-       if (response != NULL && response_len != NULL && evt_hdr->dlen) {
+       if (response != NULL && response_len != NULL && evt_hdr->dlen &&
+           evt_hdr->dlen <= payload_len) {
                /* Skip header info and copy only response data */
                skb_pull(skb, sizeof(struct fm_event_msg_hdr));
                memcpy(response, skb->data, evt_hdr->dlen);
@@ -590,6 +591,8 @@ static void fm_irq_handle_flag_getcmd_resp(struct fmdev 
*fmdev)
                return;
 
        fm_evt_hdr = (void *)skb->data;
+       if (fm_evt_hdr->dlen > sizeof(fmdev->irq_info.flag))
+               return;
 
        /* Skip header info and copy only response data */
        skb_pull(skb, sizeof(struct fm_event_msg_hdr));
@@ -1315,7 +1318,7 @@ static int load_default_rx_configuration(struct fmdev 
*fmdev)
 static int fm_power_up(struct fmdev *fmdev, u8 mode)
 {
        u16 payload;
-       __be16 asic_id, asic_ver;
+       __be16 asic_id = 0, asic_ver = 0;
        int resp_len, ret;
        u8 fw_name[50];
 
diff --git a/drivers/media/usb/au0828/au0828-video.c 
b/drivers/media/usb/au0828/au0828-video.c
index 85dd9a8e83ff..48eeb5a6a209 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -764,6 +764,9 @@ static int au0828_analog_stream_enable(struct au0828_dev *d)
 
        dprintk(1, "au0828_analog_stream_enable called\n");
 
+       if (test_bit(DEV_DISCONNECTED, &d->dev_state))
+               return -ENODEV;
+
        iface = usb_ifnum_to_if(d->usbdev, 0);
        if (iface && iface->cur_altsetting->desc.bAlternateSetting != 5) {
                dprintk(1, "Changing intf#0 to alt 5\n");
@@ -852,9 +855,9 @@ int au0828_start_analog_streaming(struct vb2_queue *vq, 
unsigned int count)
                        return rc;
                }
 
+               v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 1);
+
                if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-                       v4l2_device_call_all(&dev->v4l2_dev, 0, video,
-                                               s_stream, 1);
                        dev->vid_timeout_running = 1;
                        mod_timer(&dev->vid_timeout, jiffies + (HZ / 10));
                } else if (vq->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
@@ -874,10 +877,11 @@ static void au0828_stop_streaming(struct vb2_queue *vq)
 
        dprintk(1, "au0828_stop_streaming called %d\n", dev->streaming_users);
 
-       if (dev->streaming_users-- == 1)
+       if (dev->streaming_users-- == 1) {
                au0828_uninit_isoc(dev);
+               v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 0);
+       }
 
-       v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 0);
        dev->vid_timeout_running = 0;
        del_timer_sync(&dev->vid_timeout);
 
@@ -906,8 +910,10 @@ void au0828_stop_vbi_streaming(struct vb2_queue *vq)
        dprintk(1, "au0828_stop_vbi_streaming called %d\n",
                dev->streaming_users);
 
-       if (dev->streaming_users-- == 1)
+       if (dev->streaming_users-- == 1) {
                au0828_uninit_isoc(dev);
+               v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 0);
+       }
 
        spin_lock_irqsave(&dev->slock, flags);
        if (dev->isoc_ctl.vbi_buf != NULL) {
diff --git a/drivers/media/usb/cpia2/cpia2_v4l.c 
b/drivers/media/usb/cpia2/cpia2_v4l.c
index d793c630f1dd..05e7edb213de 100644
--- a/drivers/media/usb/cpia2/cpia2_v4l.c
+++ b/drivers/media/usb/cpia2/cpia2_v4l.c
@@ -1248,8 +1248,7 @@ static int __init cpia2_init(void)
        LOG("%s v%s\n",
            ABOUT, CPIA_VERSION);
        check_parameters();
-       cpia2_usb_init();
-       return 0;
+       return cpia2_usb_init();
 }
 
 
diff --git a/drivers/media/usb/go7007/go7007-fw.c 
b/drivers/media/usb/go7007/go7007-fw.c
index 60bf5f0644d1..a5efcd4f7b4f 100644
--- a/drivers/media/usb/go7007/go7007-fw.c
+++ b/drivers/media/usb/go7007/go7007-fw.c
@@ -1499,8 +1499,8 @@ static int modet_to_package(struct go7007 *go, __le16 
*code, int space)
        return cnt;
 }
 
-static int do_special(struct go7007 *go, u16 type, __le16 *code, int space,
-                       int *framelen)
+static noinline_for_stack int do_special(struct go7007 *go, u16 type,
+                                        __le16 *code, int space, int *framelen)
 {
        switch (type) {
        case SPECIAL_FRM_HEAD:
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c 
b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
index 1eb4f7ba2967..ff489645e070 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
@@ -670,6 +670,8 @@ static int ctrl_get_input(struct pvr2_ctrl *cptr,int *vp)
 
 static int ctrl_check_input(struct pvr2_ctrl *cptr,int v)
 {
+       if (v < 0 || v > PVR2_CVAL_INPUT_MAX)
+               return 0;
        return ((1 << v) & cptr->hdw->input_allowed_mask) != 0;
 }
 
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.h 
b/drivers/media/usb/pvrusb2/pvrusb2-hdw.h
index a82a00dd7329..80869990ffbb 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.h
@@ -54,6 +54,7 @@
 #define PVR2_CVAL_INPUT_COMPOSITE 2
 #define PVR2_CVAL_INPUT_SVIDEO 3
 #define PVR2_CVAL_INPUT_RADIO 4
+#define PVR2_CVAL_INPUT_MAX PVR2_CVAL_INPUT_RADIO
 
 enum pvr2_config {
        pvr2_config_empty,    /* No configuration */
diff --git a/drivers/mmc/core/pwrseq_emmc.c b/drivers/mmc/core/pwrseq_emmc.c
index adc9c0c614fb..4493c299d85e 100644
--- a/drivers/mmc/core/pwrseq_emmc.c
+++ b/drivers/mmc/core/pwrseq_emmc.c
@@ -30,19 +30,14 @@ struct mmc_pwrseq_emmc {
 
 #define to_pwrseq_emmc(p) container_of(p, struct mmc_pwrseq_emmc, pwrseq)
 
-static void __mmc_pwrseq_emmc_reset(struct mmc_pwrseq_emmc *pwrseq)
-{
-       gpiod_set_value(pwrseq->reset_gpio, 1);
-       udelay(1);
-       gpiod_set_value(pwrseq->reset_gpio, 0);
-       udelay(200);
-}
-
 static void mmc_pwrseq_emmc_reset(struct mmc_host *host)
 {
        struct mmc_pwrseq_emmc *pwrseq =  to_pwrseq_emmc(host->pwrseq);
 
-       __mmc_pwrseq_emmc_reset(pwrseq);
+       gpiod_set_value_cansleep(pwrseq->reset_gpio, 1);
+       udelay(1);
+       gpiod_set_value_cansleep(pwrseq->reset_gpio, 0);
+       udelay(200);
 }
 
 static int mmc_pwrseq_emmc_reset_nb(struct notifier_block *this,
@@ -50,8 +45,11 @@ static int mmc_pwrseq_emmc_reset_nb(struct notifier_block 
*this,
 {
        struct mmc_pwrseq_emmc *pwrseq = container_of(this,
                                        struct mmc_pwrseq_emmc, reset_nb);
+       gpiod_set_value(pwrseq->reset_gpio, 1);
+       udelay(1);
+       gpiod_set_value(pwrseq->reset_gpio, 0);
+       udelay(200);
 
-       __mmc_pwrseq_emmc_reset(pwrseq);
        return NOTIFY_DONE;
 }
 
@@ -72,14 +70,18 @@ static int mmc_pwrseq_emmc_probe(struct platform_device 
*pdev)
        if (IS_ERR(pwrseq->reset_gpio))
                return PTR_ERR(pwrseq->reset_gpio);
 
-       /*
-        * register reset handler to ensure emmc reset also from
-        * emergency_reboot(), priority 255 is the highest priority
-        * so it will be executed before any system reboot handler.
-        */
-       pwrseq->reset_nb.notifier_call = mmc_pwrseq_emmc_reset_nb;
-       pwrseq->reset_nb.priority = 255;
-       register_restart_handler(&pwrseq->reset_nb);
+       if (!gpiod_cansleep(pwrseq->reset_gpio)) {
+               /*
+                * register reset handler to ensure emmc reset also from
+                * emergency_reboot(), priority 255 is the highest priority
+                * so it will be executed before any system reboot handler.
+                */
+               pwrseq->reset_nb.notifier_call = mmc_pwrseq_emmc_reset_nb;
+               pwrseq->reset_nb.priority = 255;
+               register_restart_handler(&pwrseq->reset_nb);
+       } else {
+               dev_notice(dev, "EMMC reset pin tied to a sleepy GPIO driver; 
reset on emergency-reboot disabled\n");
+       }
 
        pwrseq->pwrseq.ops = &mmc_pwrseq_emmc_ops;
        pwrseq->pwrseq.dev = dev;
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index f09148a4ab55..00ba8807dafe 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -214,6 +214,14 @@ static int mmc_decode_scr(struct mmc_card *card)
 
        if (scr->sda_spec3)
                scr->cmds = UNSTUFF_BITS(resp, 32, 2);
+
+       /* SD Spec says: any SD Card shall set at least bits 0 and 2 */
+       if (!(scr->bus_widths & SD_SCR_BUS_WIDTH_1) ||
+           !(scr->bus_widths & SD_SCR_BUS_WIDTH_4)) {
+               pr_err("%s: invalid bus width\n", mmc_hostname(card->host));
+               return -EINVAL;
+       }
+
        return 0;
 }
 
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
index 6224ad37fd80..c2df68e958b3 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -819,6 +819,10 @@ mmc_spi_readblock(struct mmc_spi_host *host, struct 
spi_transfer *t,
        }
 
        status = spi_sync_locked(spi, &host->m);
+       if (status < 0) {
+               dev_dbg(&spi->dev, "read error %d\n", status);
+               return status;
+       }
 
        if (host->dma_dev) {
                dma_sync_single_for_cpu(host->dma_dev,
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c 
b/drivers/mmc/host/sdhci-of-esdhc.c
index a51d636c2312..6f11cd95bb5f 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -636,6 +636,11 @@ static int sdhci_esdhc_probe(struct platform_device *pdev)
        if (esdhc->vendor_ver > VENDOR_V_22)
                host->quirks &= ~SDHCI_QUIRK_NO_BUSY_IRQ;
 
+       if (of_find_compatible_node(NULL, NULL, "fsl,p2020-esdhc")) {
+               host->quirks2 |= SDHCI_QUIRK_RESET_AFTER_REQUEST;
+               host->quirks2 |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
+       }
+
        if (of_device_is_compatible(np, "fsl,p5040-esdhc") ||
            of_device_is_compatible(np, "fsl,p5020-esdhc") ||
            of_device_is_compatible(np, "fsl,p4080-esdhc") ||
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c 
b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 0c298878bf46..0780900b37c7 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -2116,7 +2116,7 @@ static void ena_config_host_info(struct ena_com_dev 
*ena_dev)
 
        host_info->os_type = ENA_ADMIN_OS_LINUX;
        host_info->kernel_ver = LINUX_VERSION_CODE;
-       strncpy(host_info->kernel_ver_str, utsname()->version,
+       strlcpy(host_info->kernel_ver_str, utsname()->version,
                sizeof(host_info->kernel_ver_str) - 1);
        host_info->os_dist = 0;
        strncpy(host_info->os_dist_str, utsname()->release,
diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h 
b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
index 8cffcdfd5678..38b5858c335a 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
+++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
@@ -75,8 +75,8 @@ struct l2t_data {
        struct l2t_entry *rover;        /* starting point for next allocation */
        atomic_t nfree;         /* number of free entries */
        rwlock_t lock;
-       struct l2t_entry l2tab[0];
        struct rcu_head rcu_head;       /* to handle rcu cleanup */
+       struct l2t_entry l2tab[];
 };
 
 typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index c71a52a2f801..5478a2ab45c4 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -5203,15 +5203,24 @@ static int __init cxgb4_init_module(void)
 
        ret = pci_register_driver(&cxgb4_driver);
        if (ret < 0)
-               debugfs_remove(cxgb4_debugfs_root);
+               goto err_pci;
 
 #if IS_ENABLED(CONFIG_IPV6)
        if (!inet6addr_registered) {
-               register_inet6addr_notifier(&cxgb4_inet6addr_notifier);
-               inet6addr_registered = true;
+               ret = register_inet6addr_notifier(&cxgb4_inet6addr_notifier);
+               if (ret)
+                       pci_unregister_driver(&cxgb4_driver);
+               else
+                       inet6addr_registered = true;
        }
 #endif
 
+       if (ret == 0)
+               return ret;
+
+err_pci:
+       debugfs_remove(cxgb4_debugfs_root);
+
        return ret;
 }
 
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c 
b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 7836072d3f63..886378c5334f 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -2285,6 +2285,10 @@ void i40e_vlan_stripping_enable(struct i40e_vsi *vsi)
        struct i40e_vsi_context ctxt;
        i40e_status ret;
 
+       /* Don't modify stripping options if a port VLAN is active */
+       if (vsi->info.pvid)
+               return;
+
        if ((vsi->info.valid_sections &
             cpu_to_le16(I40E_AQ_VSI_PROP_VLAN_VALID)) &&
            ((vsi->info.port_vlan_flags & I40E_AQ_VSI_PVLAN_MODE_MASK) == 0))
@@ -2315,6 +2319,10 @@ void i40e_vlan_stripping_disable(struct i40e_vsi *vsi)
        struct i40e_vsi_context ctxt;
        i40e_status ret;
 
+       /* Don't modify stripping options if a port VLAN is active */
+       if (vsi->info.pvid)
+               return;
+
        if ((vsi->info.valid_sections &
             cpu_to_le16(I40E_AQ_VSI_PROP_VLAN_VALID)) &&
            ((vsi->info.port_vlan_flags & I40E_AQ_VSI_PVLAN_EMOD_MASK) ==
diff --git a/drivers/net/wireless/atmel/at76c50x-usb.c 
b/drivers/net/wireless/atmel/at76c50x-usb.c
index 0e180677c7fc..09dbab464fe1 100644
--- a/drivers/net/wireless/atmel/at76c50x-usb.c
+++ b/drivers/net/wireless/atmel/at76c50x-usb.c
@@ -2583,8 +2583,8 @@ static int __init at76_mod_init(void)
        if (result < 0)
                printk(KERN_ERR DRIVER_NAME
                       ": usb_register failed (status %d)\n", result);
-
-       led_trigger_register_simple("at76_usb-tx", &ledtrig_tx);
+       else
+               led_trigger_register_simple("at76_usb-tx", &ledtrig_tx);
        return result;
 }
 
diff --git a/drivers/net/wireless/broadcom/b43/phy_lp.c 
b/drivers/net/wireless/broadcom/b43/phy_lp.c
index 6922cbb99a04..5a0699fb4b9a 100644
--- a/drivers/net/wireless/broadcom/b43/phy_lp.c
+++ b/drivers/net/wireless/broadcom/b43/phy_lp.c
@@ -1834,7 +1834,7 @@ static void lpphy_papd_cal(struct b43_wldev *dev, struct 
lpphy_tx_gains gains,
 static void lpphy_papd_cal_txpwr(struct b43_wldev *dev)
 {
        struct b43_phy_lp *lpphy = dev->phy.lp;
-       struct lpphy_tx_gains gains, oldgains;
+       struct lpphy_tx_gains oldgains;
        int old_txpctl, old_afe_ovr, old_rf, old_bbmult;
 
        lpphy_read_tx_pctl_mode_from_hardware(dev);
@@ -1848,9 +1848,9 @@ static void lpphy_papd_cal_txpwr(struct b43_wldev *dev)
        lpphy_set_tx_power_control(dev, B43_LPPHY_TXPCTL_OFF);
 
        if (dev->dev->chip_id == 0x4325 && dev->dev->chip_rev == 0)
-               lpphy_papd_cal(dev, gains, 0, 1, 30);
+               lpphy_papd_cal(dev, oldgains, 0, 1, 30);
        else
-               lpphy_papd_cal(dev, gains, 0, 1, 65);
+               lpphy_papd_cal(dev, oldgains, 0, 1, 65);
 
        if (old_afe_ovr)
                lpphy_set_tx_gains(dev, oldgains);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 530f52120972..8f8fe6f2af5b 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -5374,6 +5374,8 @@ static s32 brcmf_get_assoc_ies(struct brcmf_cfg80211_info 
*cfg,
                conn_info->req_ie =
                    kmemdup(cfg->extra_buf, conn_info->req_ie_len,
                            GFP_KERNEL);
+               if (!conn_info->req_ie)
+                       conn_info->req_ie_len = 0;
        } else {
                conn_info->req_ie_len = 0;
                conn_info->req_ie = NULL;
@@ -5390,6 +5392,8 @@ static s32 brcmf_get_assoc_ies(struct brcmf_cfg80211_info 
*cfg,
                conn_info->resp_ie =
                    kmemdup(cfg->extra_buf, conn_info->resp_ie_len,
                            GFP_KERNEL);
+               if (!conn_info->resp_ie)
+                       conn_info->resp_ie_len = 0;
        } else {
                conn_info->resp_ie_len = 0;
                conn_info->resp_ie = NULL;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index f877301c9454..ecfe056d7643 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -685,17 +685,17 @@ static void brcmf_del_if(struct brcmf_pub *drvr, s32 
bsscfgidx,
                         bool rtnl_locked)
 {
        struct brcmf_if *ifp;
+       int ifidx;
 
        ifp = drvr->iflist[bsscfgidx];
-       drvr->iflist[bsscfgidx] = NULL;
        if (!ifp) {
                brcmf_err("Null interface, bsscfgidx=%d\n", bsscfgidx);
                return;
        }
        brcmf_dbg(TRACE, "Enter, bsscfgidx=%d, ifidx=%d\n", bsscfgidx,
                  ifp->ifidx);
-       if (drvr->if2bss[ifp->ifidx] == bsscfgidx)
-               drvr->if2bss[ifp->ifidx] = BRCMF_BSSIDX_INVALID;
+       ifidx = ifp->ifidx;
+
        if (ifp->ndev) {
                if (bsscfgidx == 0) {
                        if (ifp->ndev->netdev_ops == &brcmf_netdev_ops_pri) {
@@ -723,6 +723,10 @@ static void brcmf_del_if(struct brcmf_pub *drvr, s32 
bsscfgidx,
                brcmf_p2p_ifp_removed(ifp, rtnl_locked);
                kfree(ifp);
        }
+
+       drvr->iflist[bsscfgidx] = NULL;
+       if (drvr->if2bss[ifidx] == bsscfgidx)
+               drvr->if2bss[ifidx] = BRCMF_BSSIDX_INVALID;
 }
 
 void brcmf_remove_interface(struct brcmf_if *ifp, bool rtnl_locked)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
index 053f3b59f21e..acf513fd9e6d 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
@@ -157,7 +157,7 @@ struct brcmf_usbdev_info {
 
        struct usb_device *usbdev;
        struct device *dev;
-       struct mutex dev_init_lock;
+       struct completion dev_init_done;
 
        int ctl_in_pipe, ctl_out_pipe;
        struct urb *ctl_urb; /* URB for control endpoint */
@@ -681,12 +681,18 @@ static int brcmf_usb_up(struct device *dev)
 
 static void brcmf_cancel_all_urbs(struct brcmf_usbdev_info *devinfo)
 {
+       int i;
+
        if (devinfo->ctl_urb)
                usb_kill_urb(devinfo->ctl_urb);
        if (devinfo->bulk_urb)
                usb_kill_urb(devinfo->bulk_urb);
-       brcmf_usb_free_q(&devinfo->tx_postq, true);
-       brcmf_usb_free_q(&devinfo->rx_postq, true);
+       if (devinfo->tx_reqs)
+               for (i = 0; i < devinfo->bus_pub.ntxq; i++)
+                       usb_kill_urb(devinfo->tx_reqs[i].urb);
+       if (devinfo->rx_reqs)
+               for (i = 0; i < devinfo->bus_pub.nrxq; i++)
+                       usb_kill_urb(devinfo->rx_reqs[i].urb);
 }
 
 static void brcmf_usb_down(struct device *dev)
@@ -1189,11 +1195,11 @@ static void brcmf_usb_probe_phase2(struct device *dev, 
int ret,
        if (ret)
                goto error;
 
-       mutex_unlock(&devinfo->dev_init_lock);
+       complete(&devinfo->dev_init_done);
        return;
 error:
        brcmf_dbg(TRACE, "failed: dev=%s, err=%d\n", dev_name(dev), ret);
-       mutex_unlock(&devinfo->dev_init_lock);
+       complete(&devinfo->dev_init_done);
        device_release_driver(dev);
 }
 
@@ -1239,7 +1245,7 @@ static int brcmf_usb_probe_cb(struct brcmf_usbdev_info 
*devinfo)
                if (ret)
                        goto fail;
                /* we are done */
-               mutex_unlock(&devinfo->dev_init_lock);
+               complete(&devinfo->dev_init_done);
                return 0;
        }
        bus->chip = bus_pub->devid;
@@ -1300,11 +1306,10 @@ brcmf_usb_probe(struct usb_interface *intf, const 
struct usb_device_id *id)
 
        devinfo->usbdev = usb;
        devinfo->dev = &usb->dev;
-       /* Take an init lock, to protect for disconnect while still loading.
+       /* Init completion, to protect for disconnect while still loading.
         * Necessary because of the asynchronous firmware load construction
         */
-       mutex_init(&devinfo->dev_init_lock);
-       mutex_lock(&devinfo->dev_init_lock);
+       init_completion(&devinfo->dev_init_done);
 
        usb_set_intfdata(intf, devinfo);
 
@@ -1382,7 +1387,7 @@ brcmf_usb_probe(struct usb_interface *intf, const struct 
usb_device_id *id)
        return 0;
 
 fail:
-       mutex_unlock(&devinfo->dev_init_lock);
+       complete(&devinfo->dev_init_done);
        kfree(devinfo);
        usb_set_intfdata(intf, NULL);
        return ret;
@@ -1397,7 +1402,7 @@ brcmf_usb_disconnect(struct usb_interface *intf)
        devinfo = (struct brcmf_usbdev_info *)usb_get_intfdata(intf);
 
        if (devinfo) {
-               mutex_lock(&devinfo->dev_init_lock);
+               wait_for_completion(&devinfo->dev_init_done);
                /* Make sure that devinfo still exists. Firmware probe routines
                 * may have released the device and cleared the intfdata.
                 */
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c
index 8eff2753abad..d493021f6031 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c
@@ -35,9 +35,10 @@ static int brcmf_cfg80211_vndr_cmds_dcmd_handler(struct 
wiphy *wiphy,
        struct brcmf_if *ifp;
        const struct brcmf_vndr_dcmd_hdr *cmdhdr = data;
        struct sk_buff *reply;
-       int ret, payload, ret_len;
+       unsigned int payload, ret_len;
        void *dcmd_buf = NULL, *wr_pointer;
        u16 msglen, maxmsglen = PAGE_SIZE - 0x100;
+       int ret;
 
        if (len < sizeof(*cmdhdr)) {
                brcmf_err("vendor command too short: %d\n", len);
@@ -65,7 +66,7 @@ static int brcmf_cfg80211_vndr_cmds_dcmd_handler(struct wiphy 
*wiphy,
                        brcmf_err("oversize return buffer %d\n", ret_len);
                        ret_len = BRCMF_DCMD_MAXLEN;
                }
-               payload = max(ret_len, len) + 1;
+               payload = max_t(unsigned int, ret_len, len) + 1;
                dcmd_buf = vzalloc(payload);
                if (NULL == dcmd_buf)
                        return -ENOMEM;
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
index c21f8bd32d08..25f2a0aceaa2 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
@@ -1225,10 +1225,15 @@ static void iwl_pcie_rx_handle_rb(struct iwl_trans 
*trans,
 static void iwl_pcie_rx_handle(struct iwl_trans *trans, int queue)
 {
        struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
-       struct iwl_rxq *rxq = &trans_pcie->rxq[queue];
+       struct iwl_rxq *rxq;
        u32 r, i, count = 0;
        bool emergency = false;
 
+       if (WARN_ON_ONCE(!trans_pcie->rxq || !trans_pcie->rxq[queue].bd))
+               return;
+
+       rxq = &trans_pcie->rxq[queue];
+
 restart:
        spin_lock(&rxq->lock);
        /* uCode's read index (stored in shared DRAM) indicates the last Rx
diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c 
b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
index 4da3541471e6..46d0099fd6e8 100644
--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
@@ -4018,16 +4018,20 @@ static int mwifiex_tm_cmd(struct wiphy *wiphy, struct 
wireless_dev *wdev,
 
                if (mwifiex_send_cmd(priv, 0, 0, 0, hostcmd, true)) {
                        dev_err(priv->adapter->dev, "Failed to process 
hostcmd\n");
+                       kfree(hostcmd);
                        return -EFAULT;
                }
 
                /* process hostcmd response*/
                skb = cfg80211_testmode_alloc_reply_skb(wiphy, hostcmd->len);
-               if (!skb)
+               if (!skb) {
+                       kfree(hostcmd);
                        return -ENOMEM;
+               }
                err = nla_put(skb, MWIFIEX_TM_ATTR_DATA,
                              hostcmd->len, hostcmd->cmd);
                if (err) {
+                       kfree(hostcmd);
                        kfree_skb(skb);
                        return -EMSGSIZE;
                }
diff --git a/drivers/net/wireless/marvell/mwifiex/cfp.c 
b/drivers/net/wireless/marvell/mwifiex/cfp.c
index 1ff22055e54f..9ddaa767ea74 100644
--- a/drivers/net/wireless/marvell/mwifiex/cfp.c
+++ b/drivers/net/wireless/marvell/mwifiex/cfp.c
@@ -533,5 +533,8 @@ u8 mwifiex_adjust_data_rate(struct mwifiex_private *priv,
                rate_index = (rx_rate > MWIFIEX_RATE_INDEX_OFDM0) ?
                              rx_rate - 1 : rx_rate;
 
+       if (rate_index >= MWIFIEX_MAX_AC_RX_RATES)
+               rate_index = MWIFIEX_MAX_AC_RX_RATES - 1;
+
        return rate_index;
 }
diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c 
b/drivers/net/wireless/realtek/rtlwifi/base.c
index 4ac928bf1f8e..7de18ed10db8 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -466,6 +466,11 @@ static void _rtl_init_deferred_work(struct ieee80211_hw 
*hw)
        /* <2> work queue */
        rtlpriv->works.hw = hw;
        rtlpriv->works.rtl_wq = alloc_workqueue("%s", 0, 0, rtlpriv->cfg->name);
+       if (unlikely(!rtlpriv->works.rtl_wq)) {
+               pr_err("Failed to allocate work queue\n");
+               return;
+       }
+
        INIT_DELAYED_WORK(&rtlpriv->works.watchdog_wq,
                          (void *)rtl_watchdog_wq_callback);
        INIT_DELAYED_WORK(&rtlpriv->works.ips_nic_off_wq,
diff --git a/drivers/net/wireless/st/cw1200/main.c 
b/drivers/net/wireless/st/cw1200/main.c
index dc478cedbde0..84624c812a15 100644
--- a/drivers/net/wireless/st/cw1200/main.c
+++ b/drivers/net/wireless/st/cw1200/main.c
@@ -345,6 +345,11 @@ static struct ieee80211_hw *cw1200_init_common(const u8 
*macaddr,
        mutex_init(&priv->wsm_cmd_mux);
        mutex_init(&priv->conf_mutex);
        priv->workqueue = create_singlethread_workqueue("cw1200_wq");
+       if (!priv->workqueue) {
+               ieee80211_free_hw(hw);
+               return NULL;
+       }
+
        sema_init(&priv->scan.lock, 1);
        INIT_WORK(&priv->scan.work, cw1200_scan_work);
        INIT_DELAYED_WORK(&priv->scan.probe_work, cw1200_probe_work);
diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c
index 66a089d561cf..9108004a0d9b 100644
--- a/drivers/nvdimm/label.c
+++ b/drivers/nvdimm/label.c
@@ -490,15 +490,26 @@ static unsigned long nd_label_offset(struct 
nvdimm_drvdata *ndd,
                - (unsigned long) to_namespace_index(ndd, 0);
 }
 
+static void reap_victim(struct nd_mapping *nd_mapping,
+               struct nd_label_ent *victim)
+{
+       struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
+       u32 slot = to_slot(ndd, victim->label);
+
+       dev_dbg(ndd->dev, "free: %d\n", slot);
+       nd_label_free_slot(ndd, slot);
+       victim->label = NULL;
+}
+
 static int __pmem_label_update(struct nd_region *nd_region,
                struct nd_mapping *nd_mapping, struct nd_namespace_pmem *nspm,
                int pos, unsigned long flags)
 {
        u64 cookie = nd_region_interleave_set_cookie(nd_region);
        struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
-       struct nd_label_ent *label_ent, *victim = NULL;
        struct nd_namespace_label *nd_label;
        struct nd_namespace_index *nsindex;
+       struct nd_label_ent *label_ent;
        struct nd_label_id label_id;
        struct resource *res;
        unsigned long *free;
@@ -551,18 +562,10 @@ static int __pmem_label_update(struct nd_region 
*nd_region,
        list_for_each_entry(label_ent, &nd_mapping->labels, list) {
                if (!label_ent->label)
                        continue;
-               if (memcmp(nspm->uuid, label_ent->label->uuid,
-                                       NSLABEL_UUID_LEN) != 0)
-                       continue;
-               victim = label_ent;
-               list_move_tail(&victim->list, &nd_mapping->labels);
-               break;
-       }
-       if (victim) {
-               dev_dbg(ndd->dev, "%s: free: %d\n", __func__, slot);
-               slot = to_slot(ndd, victim->label);
-               nd_label_free_slot(ndd, slot);
-               victim->label = NULL;
+               if (test_and_clear_bit(ND_LABEL_REAP, &label_ent->flags)
+                               || memcmp(nspm->uuid, label_ent->label->uuid,
+                                       NSLABEL_UUID_LEN) == 0)
+                       reap_victim(nd_mapping, label_ent);
        }
 
        /* update index */
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index cf4a90b50f8b..e83453e1b308 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -1210,12 +1210,27 @@ static int namespace_update_uuid(struct nd_region 
*nd_region,
        for (i = 0; i < nd_region->ndr_mappings; i++) {
                struct nd_mapping *nd_mapping = &nd_region->mapping[i];
                struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
+               struct nd_label_ent *label_ent;
                struct resource *res;
 
                for_each_dpa_resource(ndd, res)
                        if (strcmp(res->name, old_label_id.id) == 0)
                                sprintf((void *) res->name, "%s",
                                                new_label_id.id);
+
+               mutex_lock(&nd_mapping->lock);
+               list_for_each_entry(label_ent, &nd_mapping->labels, list) {
+                       struct nd_namespace_label *nd_label = label_ent->label;
+                       struct nd_label_id label_id;
+
+                       if (!nd_label)
+                               continue;
+                       nd_label_gen_id(&label_id, nd_label->uuid,
+                                       __le32_to_cpu(nd_label->flags));
+                       if (strcmp(old_label_id.id, label_id.id) == 0)
+                               set_bit(ND_LABEL_REAP, &label_ent->flags);
+               }
+               mutex_unlock(&nd_mapping->lock);
        }
        kfree(*old_uuid);
  out:
diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h
index d869236b474f..bd29e598bac1 100644
--- a/drivers/nvdimm/nd.h
+++ b/drivers/nvdimm/nd.h
@@ -113,8 +113,12 @@ struct nd_percpu_lane {
        spinlock_t lock;
 };
 
+enum nd_label_flags {
+       ND_LABEL_REAP,
+};
 struct nd_label_ent {
        struct list_head list;
+       unsigned long flags;
        struct nd_namespace_label *label;
 };
 
diff --git a/drivers/pinctrl/pinctrl-pistachio.c 
b/drivers/pinctrl/pinctrl-pistachio.c
index 55375b1b3cc8..b2b7e238bda9 100644
--- a/drivers/pinctrl/pinctrl-pistachio.c
+++ b/drivers/pinctrl/pinctrl-pistachio.c
@@ -1368,6 +1368,7 @@ static int pistachio_gpio_register(struct 
pistachio_pinctrl *pctl)
                if (!of_find_property(child, "gpio-controller", NULL)) {
                        dev_err(pctl->dev,
                                "No gpio-controller property for bank %u\n", i);
+                       of_node_put(child);
                        ret = -ENODEV;
                        goto err;
                }
@@ -1375,6 +1376,7 @@ static int pistachio_gpio_register(struct 
pistachio_pinctrl *pctl)
                irq = irq_of_parse_and_map(child, 0);
                if (irq < 0) {
                        dev_err(pctl->dev, "No IRQ for bank %u: %d\n", i, irq);
+                       of_node_put(child);
                        ret = irq;
                        goto err;
                }
diff --git a/drivers/rtc/rtc-88pm860x.c b/drivers/rtc/rtc-88pm860x.c
index 19e53b3b8e00..166faae3a59c 100644
--- a/drivers/rtc/rtc-88pm860x.c
+++ b/drivers/rtc/rtc-88pm860x.c
@@ -414,7 +414,7 @@ static int pm860x_rtc_remove(struct platform_device *pdev)
        struct pm860x_rtc_info *info = platform_get_drvdata(pdev);
 
 #ifdef VRTC_CALIBRATION
-       flush_scheduled_work();
+       cancel_delayed_work_sync(&info->calib_work);
        /* disable measurement */
        pm860x_set_bits(info->i2c, PM8607_MEAS_EN2, MEAS2_VRTC, 0);
 #endif /* VRTC_CALIBRATION */
diff --git a/drivers/s390/cio/cio.h b/drivers/s390/cio/cio.h
index f0e57aefb5f2..d167652a6a23 100644
--- a/drivers/s390/cio/cio.h
+++ b/drivers/s390/cio/cio.h
@@ -114,7 +114,7 @@ struct subchannel {
        struct schib_config config;
 } __attribute__ ((aligned(8)));
 
-DECLARE_PER_CPU(struct irb, cio_irb);
+DECLARE_PER_CPU_ALIGNED(struct irb, cio_irb);
 
 #define to_subchannel(n) container_of(n, struct subchannel, dev)
 
diff --git a/drivers/scsi/libsas/sas_expander.c 
b/drivers/scsi/libsas/sas_expander.c
index 1a6f65db615e..ee1f9ee995e5 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -2027,6 +2027,11 @@ static int sas_rediscover_dev(struct domain_device *dev, 
int phy_id, bool last)
        if ((SAS_ADDR(sas_addr) == 0) || (res == -ECOMM)) {
                phy->phy_state = PHY_EMPTY;
                sas_unregister_devs_sas_addr(dev, phy_id, last);
+               /*
+                * Even though the PHY is empty, for convenience we discover
+                * the PHY to update the PHY info, like negotiated linkrate.
+                */
+               sas_ex_phy_discover(dev, phy_id);
                return res;
        } else if (SAS_ADDR(sas_addr) == SAS_ADDR(phy->attached_sas_addr) &&
                   dev_type_flutter(type, phy->attached_dev_type)) {
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index 4ac03b16d17f..52afbcff362f 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -1561,6 +1561,9 @@ lpfc_fdmi_hba_attr_manufacturer(struct lpfc_vport *vport,
        ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
        memset(ae, 0, 256);
 
+       /* This string MUST be consistent with other FC platforms
+        * supported by Broadcom.
+        */
        strncpy(ae->un.AttrString,
                "Emulex Corporation",
                       sizeof(ae->un.AttrString));
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 81736457328a..9cca5ddbc50c 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -901,7 +901,11 @@ lpfc_linkdown(struct lpfc_hba *phba)
                        lpfc_linkdown_port(vports[i]);
                }
        lpfc_destroy_vport_work_array(phba, vports);
-       /* Clean up any firmware default rpi's */
+
+       /* Clean up any SLI3 firmware default rpi's */
+       if (phba->sli_rev > LPFC_SLI_REV3)
+               goto skip_unreg_did;
+
        mb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
        if (mb) {
                lpfc_unreg_did(phba, 0xffff, LPFC_UNREG_ALL_DFLT_RPIS, mb);
@@ -913,6 +917,7 @@ lpfc_linkdown(struct lpfc_hba *phba)
                }
        }
 
+ skip_unreg_did:
        /* Setup myDID for link up if we are in pt2pt mode */
        if (phba->pport->fc_flag & FC_PT2PT) {
                phba->pport->fc_myDID = 0;
@@ -4654,6 +4659,10 @@ lpfc_unreg_default_rpis(struct lpfc_vport *vport)
        LPFC_MBOXQ_t     *mbox;
        int rc;
 
+       /* Unreg DID is an SLI3 operation. */
+       if (phba->sli_rev > LPFC_SLI_REV3)
+               return;
+
        mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
        if (mbox) {
                lpfc_unreg_did(phba, vport->vpi, LPFC_UNREG_ALL_DFLT_RPIS,
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 73c99f237b10..f0fcff032f8a 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -3089,7 +3089,7 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct 
rsp_que *rsp)
                ql_log(ql_log_fatal, vha, 0x00c8,
                    "Failed to allocate memory for ha->msix_entries.\n");
                ret = -ENOMEM;
-               goto msix_out;
+               goto free_irqs;
        }
        ha->flags.msix_enabled = 1;
 
@@ -3177,6 +3177,10 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct 
rsp_que *rsp)
 msix_out:
        kfree(entries);
        return ret;
+
+free_irqs:
+       pci_free_irq_vectors(ha->pdev);
+       goto msix_out;
 }
 
 int
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index c158967b59d7..d220b4f691c7 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -5939,7 +5939,7 @@ static int get_fw_boot_info(struct scsi_qla_host *ha, 
uint16_t ddb_index[])
                val = rd_nvram_byte(ha, sec_addr);
                if (val & BIT_7)
                        ddb_index[1] = (val & 0x7f);
-
+               goto exit_boot_info;
        } else if (is_qla80XX(ha)) {
                buf = dma_alloc_coherent(&ha->pdev->dev, size,
                                         &buf_dma, GFP_KERNEL);
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 58345d3d4682..b40fe8d583c0 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2403,7 +2403,6 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, 
unsigned char *buffer)
        int res;
        struct scsi_device *sdp = sdkp->device;
        struct scsi_mode_data data;
-       int disk_ro = get_disk_ro(sdkp->disk);
        int old_wp = sdkp->write_prot;
 
        set_disk_ro(sdkp->disk, 0);
@@ -2444,7 +2443,7 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, 
unsigned char *buffer)
                          "Test WP failed, assume Write Enabled\n");
        } else {
                sdkp->write_prot = ((data.device_specific & 0x80) != 0);
-               set_disk_ro(sdkp->disk, sdkp->write_prot || disk_ro);
+               set_disk_ro(sdkp->disk, sdkp->write_prot);
                if (sdkp->first_scan || old_wp != sdkp->write_prot) {
                        sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n",
                                  sdkp->write_prot ? "on" : "off");
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 0b858414c558..0fe4f8e8c8c9 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -4875,19 +4875,19 @@ static u32 ufshcd_find_max_sup_active_icc_level(struct 
ufs_hba *hba,
                goto out;
        }
 
-       if (hba->vreg_info.vcc)
+       if (hba->vreg_info.vcc && hba->vreg_info.vcc->max_uA)
                icc_level = ufshcd_get_max_icc_level(
                                hba->vreg_info.vcc->max_uA,
                                POWER_DESC_MAX_ACTV_ICC_LVLS - 1,
                                &desc_buf[PWR_DESC_ACTIVE_LVLS_VCC_0]);
 
-       if (hba->vreg_info.vccq)
+       if (hba->vreg_info.vccq && hba->vreg_info.vccq->max_uA)
                icc_level = ufshcd_get_max_icc_level(
                                hba->vreg_info.vccq->max_uA,
                                icc_level,
                                &desc_buf[PWR_DESC_ACTIVE_LVLS_VCCQ_0]);
 
-       if (hba->vreg_info.vccq2)
+       if (hba->vreg_info.vccq2 && hba->vreg_info.vccq2->max_uA)
                icc_level = ufshcd_get_max_icc_level(
                                hba->vreg_info.vccq2->max_uA,
                                icc_level,
@@ -5449,6 +5449,15 @@ static int ufshcd_config_vreg_load(struct device *dev, 
struct ufs_vreg *vreg,
        if (!vreg)
                return 0;
 
+       /*
+        * "set_load" operation shall be required on those regulators
+        * which specifically configured current limitation. Otherwise
+        * zero max_uA may cause unexpected behavior when regulator is
+        * enabled or set as high power mode.
+        */
+       if (!vreg->max_uA)
+               return 0;
+
        ret = regulator_set_load(vreg->reg, ua);
        if (ret < 0) {
                dev_err(dev, "%s: %s set load (ua=%d) failed, err=%d\n",
@@ -5495,12 +5504,15 @@ static int ufshcd_config_vreg(struct device *dev,
        name = vreg->name;
 
        if (regulator_count_voltages(reg) > 0) {
-               min_uV = on ? vreg->min_uV : 0;
-               ret = regulator_set_voltage(reg, min_uV, vreg->max_uV);
-               if (ret) {
-                       dev_err(dev, "%s: %s set voltage failed, err=%d\n",
+               if (vreg->min_uV && vreg->max_uV) {
+                       min_uV = on ? vreg->min_uV : 0;
+                       ret = regulator_set_voltage(reg, min_uV, vreg->max_uV);
+                       if (ret) {
+                               dev_err(dev,
+                                       "%s: %s set voltage failed, err=%d\n",
                                        __func__, name, ret);
-                       goto out;
+                               goto out;
+                       }
                }
 
                uA_load = on ? vreg->max_uA : 0;
diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index f2209ec4cb68..8b618f0fa459 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -921,10 +921,14 @@ static unsigned int ssp_get_clk_div(struct driver_data 
*drv_data, int rate)
 
        rate = min_t(int, ssp_clk, rate);
 
+       /*
+        * Calculate the divisor for the SCR (Serial Clock Rate), avoiding
+        * that the SSP transmission rate can be greater than the device rate
+        */
        if (ssp->type == PXA25x_SSP || ssp->type == CE4100_SSP)
-               return (ssp_clk / (2 * rate) - 1) & 0xff;
+               return (DIV_ROUND_UP(ssp_clk, 2 * rate) - 1) & 0xff;
        else
-               return (ssp_clk / rate - 1) & 0xfff;
+               return (DIV_ROUND_UP(ssp_clk, rate) - 1)  & 0xfff;
 }
 
 static unsigned int pxa2xx_ssp_get_clk_div(struct driver_data *drv_data,
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index 093c9cf92bfd..07612e8c58ee 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -279,7 +279,8 @@ static int rspi_set_config_register(struct rspi_data *rspi, 
int access_size)
        /* Sets parity, interrupt mask */
        rspi_write8(rspi, 0x00, RSPI_SPCR2);
 
-       /* Sets SPCMD */
+       /* Resets sequencer */
+       rspi_write8(rspi, 0, RSPI_SPSCR);
        rspi->spcmd |= SPCMD_SPB_8_TO_16(access_size);
        rspi_write16(rspi, rspi->spcmd, RSPI_SPCMD0);
 
@@ -323,7 +324,8 @@ static int rspi_rz_set_config_register(struct rspi_data 
*rspi, int access_size)
        rspi_write8(rspi, 0x00, RSPI_SSLND);
        rspi_write8(rspi, 0x00, RSPI_SPND);
 
-       /* Sets SPCMD */
+       /* Resets sequencer */
+       rspi_write8(rspi, 0, RSPI_SPSCR);
        rspi->spcmd |= SPCMD_SPB_8_TO_16(access_size);
        rspi_write16(rspi, rspi->spcmd, RSPI_SPCMD0);
 
@@ -374,7 +376,8 @@ static int qspi_set_config_register(struct rspi_data *rspi, 
int access_size)
        /* Sets buffer to allow normal operation */
        rspi_write8(rspi, 0x00, QSPI_SPBFCR);
 
-       /* Sets SPCMD */
+       /* Resets sequencer */
+       rspi_write8(rspi, 0, RSPI_SPSCR);
        rspi_write16(rspi, rspi->spcmd, RSPI_SPCMD0);
 
        /* Enables SPI function in master mode */
diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c
index 73779cecc3bb..705f515863d4 100644
--- a/drivers/spi/spi-tegra114.c
+++ b/drivers/spi/spi-tegra114.c
@@ -1067,27 +1067,19 @@ static int tegra_spi_probe(struct platform_device *pdev)
 
        spi_irq = platform_get_irq(pdev, 0);
        tspi->irq = spi_irq;
-       ret = request_threaded_irq(tspi->irq, tegra_spi_isr,
-                       tegra_spi_isr_thread, IRQF_ONESHOT,
-                       dev_name(&pdev->dev), tspi);
-       if (ret < 0) {
-               dev_err(&pdev->dev, "Failed to register ISR for IRQ %d\n",
-                                       tspi->irq);
-               goto exit_free_master;
-       }
 
        tspi->clk = devm_clk_get(&pdev->dev, "spi");
        if (IS_ERR(tspi->clk)) {
                dev_err(&pdev->dev, "can not get clock\n");
                ret = PTR_ERR(tspi->clk);
-               goto exit_free_irq;
+               goto exit_free_master;
        }
 
        tspi->rst = devm_reset_control_get(&pdev->dev, "spi");
        if (IS_ERR(tspi->rst)) {
                dev_err(&pdev->dev, "can not get reset\n");
                ret = PTR_ERR(tspi->rst);
-               goto exit_free_irq;
+               goto exit_free_master;
        }
 
        tspi->max_buf_size = SPI_FIFO_DEPTH << 2;
@@ -1095,7 +1087,7 @@ static int tegra_spi_probe(struct platform_device *pdev)
 
        ret = tegra_spi_init_dma_param(tspi, true);
        if (ret < 0)
-               goto exit_free_irq;
+               goto exit_free_master;
        ret = tegra_spi_init_dma_param(tspi, false);
        if (ret < 0)
                goto exit_rx_dma_free;
@@ -1117,18 +1109,32 @@ static int tegra_spi_probe(struct platform_device *pdev)
                dev_err(&pdev->dev, "pm runtime get failed, e = %d\n", ret);
                goto exit_pm_disable;
        }
+
+       reset_control_assert(tspi->rst);
+       udelay(2);
+       reset_control_deassert(tspi->rst);
        tspi->def_command1_reg  = SPI_M_S;
        tegra_spi_writel(tspi, tspi->def_command1_reg, SPI_COMMAND1);
        pm_runtime_put(&pdev->dev);
+       ret = request_threaded_irq(tspi->irq, tegra_spi_isr,
+                                  tegra_spi_isr_thread, IRQF_ONESHOT,
+                                  dev_name(&pdev->dev), tspi);
+       if (ret < 0) {
+               dev_err(&pdev->dev, "Failed to register ISR for IRQ %d\n",
+                       tspi->irq);
+               goto exit_pm_disable;
+       }
 
        master->dev.of_node = pdev->dev.of_node;
        ret = devm_spi_register_master(&pdev->dev, master);
        if (ret < 0) {
                dev_err(&pdev->dev, "can not register to master err %d\n", ret);
-               goto exit_pm_disable;
+               goto exit_free_irq;
        }
        return ret;
 
+exit_free_irq:
+       free_irq(spi_irq, tspi);
 exit_pm_disable:
        pm_runtime_disable(&pdev->dev);
        if (!pm_runtime_status_suspended(&pdev->dev))
@@ -1136,8 +1142,6 @@ static int tegra_spi_probe(struct platform_device *pdev)
        tegra_spi_deinit_dma_param(tspi, false);
 exit_rx_dma_free:
        tegra_spi_deinit_dma_param(tspi, true);
-exit_free_irq:
-       free_irq(spi_irq, tspi);
 exit_free_master:
        spi_master_put(master);
        return ret;
diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
index c54ee6674471..fe707440f8c3 100644
--- a/drivers/spi/spi-topcliff-pch.c
+++ b/drivers/spi/spi-topcliff-pch.c
@@ -1306,18 +1306,27 @@ static void pch_free_dma_buf(struct pch_spi_board_data 
*board_dat,
        return;
 }
 
-static void pch_alloc_dma_buf(struct pch_spi_board_data *board_dat,
+static int pch_alloc_dma_buf(struct pch_spi_board_data *board_dat,
                              struct pch_spi_data *data)
 {
        struct pch_spi_dma_ctrl *dma;
+       int ret;
 
        dma = &data->dma;
+       ret = 0;
        /* Get Consistent memory for Tx DMA */
        dma->tx_buf_virt = dma_alloc_coherent(&board_dat->pdev->dev,
                                PCH_BUF_SIZE, &dma->tx_buf_dma, GFP_KERNEL);
+       if (!dma->tx_buf_virt)
+               ret = -ENOMEM;
+
        /* Get Consistent memory for Rx DMA */
        dma->rx_buf_virt = dma_alloc_coherent(&board_dat->pdev->dev,
                                PCH_BUF_SIZE, &dma->rx_buf_dma, GFP_KERNEL);
+       if (!dma->rx_buf_virt)
+               ret = -ENOMEM;
+
+       return ret;
 }
 
 static int pch_spi_pd_probe(struct platform_device *plat_dev)
@@ -1394,7 +1403,9 @@ static int pch_spi_pd_probe(struct platform_device 
*plat_dev)
 
        if (use_dma) {
                dev_info(&plat_dev->dev, "Use DMA for data transfers\n");
-               pch_alloc_dma_buf(board_dat, data);
+               ret = pch_alloc_dma_buf(board_dat, data);
+               if (ret)
+                       goto err_spi_register_master;
        }
 
        ret = spi_register_master(master);
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index c2e85e23d538..d74d341f9890 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -955,6 +955,8 @@ static int spi_map_msg(struct spi_master *master, struct 
spi_message *msg)
                if (max_tx || max_rx) {
                        list_for_each_entry(xfer, &msg->transfers,
                                            transfer_list) {
+                               if (!xfer->len)
+                                       continue;
                                if (!xfer->tx_buf)
                                        xfer->tx_buf = master->dummy_tx;
                                if (!xfer->rx_buf)
diff --git a/drivers/ssb/bridge_pcmcia_80211.c 
b/drivers/ssb/bridge_pcmcia_80211.c
index d70568ea02d5..2ff7d90e166a 100644
--- a/drivers/ssb/bridge_pcmcia_80211.c
+++ b/drivers/ssb/bridge_pcmcia_80211.c
@@ -113,16 +113,21 @@ static struct pcmcia_driver ssb_host_pcmcia_driver = {
        .resume         = ssb_host_pcmcia_resume,
 };
 
+static int pcmcia_init_failed;
+
 /*
  * These are not module init/exit functions!
  * The module_pcmcia_driver() helper cannot be used here.
  */
 int ssb_host_pcmcia_init(void)
 {
-       return pcmcia_register_driver(&ssb_host_pcmcia_driver);
+       pcmcia_init_failed = pcmcia_register_driver(&ssb_host_pcmcia_driver);
+
+       return pcmcia_init_failed;
 }
 
 void ssb_host_pcmcia_exit(void)
 {
-       pcmcia_unregister_driver(&ssb_host_pcmcia_driver);
+       if (!pcmcia_init_failed)
+               pcmcia_unregister_driver(&ssb_host_pcmcia_driver);
 }
diff --git a/drivers/tty/ipwireless/main.c b/drivers/tty/ipwireless/main.c
index 655c7948261c..2fa4f9123469 100644
--- a/drivers/tty/ipwireless/main.c
+++ b/drivers/tty/ipwireless/main.c
@@ -113,6 +113,10 @@ static int ipwireless_probe(struct pcmcia_device *p_dev, 
void *priv_data)
 
        ipw->common_memory = ioremap(p_dev->resource[2]->start,
                                resource_size(p_dev->resource[2]));
+       if (!ipw->common_memory) {
+               ret = -ENOMEM;
+               goto exit1;
+       }
        if (!request_mem_region(p_dev->resource[2]->start,
                                resource_size(p_dev->resource[2]),
                                IPWIRELESS_PCCARD_NAME)) {
@@ -133,6 +137,10 @@ static int ipwireless_probe(struct pcmcia_device *p_dev, 
void *priv_data)
 
        ipw->attr_memory = ioremap(p_dev->resource[3]->start,
                                resource_size(p_dev->resource[3]));
+       if (!ipw->attr_memory) {
+               ret = -ENOMEM;
+               goto exit3;
+       }
        if (!request_mem_region(p_dev->resource[3]->start,
                                resource_size(p_dev->resource[3]),
                                IPWIRELESS_PCCARD_NAME)) {
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index bdb0d7a08ff9..1dd4c65e9188 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -3033,6 +3033,9 @@ usb_hcd_platform_shutdown(struct platform_device *dev)
 {
        struct usb_hcd *hcd = platform_get_drvdata(dev);
 
+       /* No need for pm_runtime_put(), we're shutting down */
+       pm_runtime_get_sync(&dev->dev);
+
        if (hcd->driver->shutdown)
                hcd->driver->shutdown(hcd);
 }
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 8fddb94f1874..3941df076cca 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -5703,7 +5703,10 @@ int usb_reset_device(struct usb_device *udev)
                                        cintf->needs_binding = 1;
                        }
                }
-               usb_unbind_and_rebind_marked_interfaces(udev);
+
+               /* If the reset failed, hub_wq will unbind drivers later */
+               if (ret == 0)
+                       usb_unbind_and_rebind_marked_interfaces(udev);
        }
 
        usb_autosuspend_device(udev);
diff --git a/drivers/video/fbdev/core/fbcmap.c 
b/drivers/video/fbdev/core/fbcmap.c
index 68a113594808..2811c4afde01 100644
--- a/drivers/video/fbdev/core/fbcmap.c
+++ b/drivers/video/fbdev/core/fbcmap.c
@@ -94,6 +94,8 @@ int fb_alloc_cmap_gfp(struct fb_cmap *cmap, int len, int 
transp, gfp_t flags)
        int size = len * sizeof(u16);
        int ret = -ENOMEM;
 
+       flags |= __GFP_NOWARN;
+
        if (cmap->len != len) {
                fb_dealloc_cmap(cmap);
                if (!len)
diff --git a/drivers/video/fbdev/core/modedb.c 
b/drivers/video/fbdev/core/modedb.c
index de119f11b78f..455a15f70172 100644
--- a/drivers/video/fbdev/core/modedb.c
+++ b/drivers/video/fbdev/core/modedb.c
@@ -933,6 +933,9 @@ void fb_var_to_videomode(struct fb_videomode *mode,
        if (var->vmode & FB_VMODE_DOUBLE)
                vtotal *= 2;
 
+       if (!htotal || !vtotal)
+               return;
+
        hfreq = pixclock/htotal;
        mode->refresh = hfreq/vtotal;
 }
diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c
index f4bc8c100a01..a3ac582420ec 100644
--- a/drivers/w1/w1_io.c
+++ b/drivers/w1/w1_io.c
@@ -437,8 +437,7 @@ int w1_reset_resume_command(struct w1_master *dev)
        if (w1_reset_bus(dev))
                return -1;
 
-       /* This will make only the last matched slave perform a skip ROM. */
-       w1_write_8(dev, W1_RESUME_CMD);
+       w1_write_8(dev, dev->slave_count > 1 ? W1_RESUME_CMD : W1_SKIP_ROM);
        return 0;
 }
 EXPORT_SYMBOL_GPL(w1_reset_resume_command);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 6b29165f766f..7938c48c72ff 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -11150,9 +11150,9 @@ int btrfs_error_unpin_extent_range(struct btrfs_root 
*root, u64 start, u64 end)
  * transaction.
  */
 static int btrfs_trim_free_extents(struct btrfs_device *device,
-                                  struct fstrim_range *range, u64 *trimmed)
+                                  u64 minlen, u64 *trimmed)
 {
-       u64 start = range->start, len = 0;
+       u64 start = 0, len = 0;
        int ret;
 
        *trimmed = 0;
@@ -11188,8 +11188,8 @@ static int btrfs_trim_free_extents(struct btrfs_device 
*device,
                        atomic_inc(&trans->use_count);
                spin_unlock(&fs_info->trans_lock);
 
-               ret = find_free_dev_extent_start(trans, device, range->minlen,
-                                                start, &start, &len);
+               ret = find_free_dev_extent_start(trans, device, minlen, start,
+                                                &start, &len);
                if (trans)
                        btrfs_put_transaction(trans);
 
@@ -11201,16 +11201,6 @@ static int btrfs_trim_free_extents(struct btrfs_device 
*device,
                        break;
                }
 
-               /* If we are out of the passed range break */
-               if (start > range->start + range->len - 1) {
-                       mutex_unlock(&fs_info->chunk_mutex);
-                       ret = 0;
-                       break;
-               }
-
-               start = max(range->start, start);
-               len = min(range->len, len);
-
                ret = btrfs_issue_discard(device->bdev, start, len, &bytes);
                up_read(&fs_info->commit_root_sem);
                mutex_unlock(&fs_info->chunk_mutex);
@@ -11221,10 +11211,6 @@ static int btrfs_trim_free_extents(struct btrfs_device 
*device,
                start += len;
                *trimmed += bytes;
 
-               /* We've trimmed enough */
-               if (*trimmed >= range->len)
-                       break;
-
                if (fatal_signal_pending(current)) {
                        ret = -ERESTARTSYS;
                        break;
@@ -11309,7 +11295,8 @@ int btrfs_trim_fs(struct btrfs_root *root, struct 
fstrim_range *range)
        mutex_lock(&fs_info->fs_devices->device_list_mutex);
        devices = &fs_info->fs_devices->devices;
        list_for_each_entry(device, devices, dev_list) {
-               ret = btrfs_trim_free_extents(device, range, &group_trimmed);
+               ret = btrfs_trim_free_extents(device, range->minlen,
+                                             &group_trimmed);
                if (ret) {
                        dev_failed++;
                        dev_ret = ret;
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 437544846e4e..c77114ce884b 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1951,6 +1951,18 @@ int btrfs_sync_file(struct file *file, loff_t start, 
loff_t end, int datasync)
        bool full_sync = 0;
        u64 len;
 
+       /*
+        * If the inode needs a full sync, make sure we use a full range to
+        * avoid log tree corruption, due to hole detection racing with ordered
+        * extent completion for adjacent ranges, and assertion failures during
+        * hole detection.
+        */
+       if (test_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
+                    &BTRFS_I(inode)->runtime_flags)) {
+               start = 0;
+               end = LLONG_MAX;
+       }
+
        /*
         * The range length can be represented by u64, we have to do the 
typecasts
         * to avoid signed overflow if it's [0, LLONG_MAX] eg. from fsync()
diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
index edae751e870c..307b8baaf0e9 100644
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -144,10 +144,8 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, 
struct btrfs_root
                return -ENOMEM;
 
        ret = btrfs_search_slot(trans, root, key, path, 0, 1);
-       if (ret < 0) {
-               btrfs_abort_transaction(trans, ret);
+       if (ret < 0)
                goto out;
-       }
 
        if (ret != 0) {
                btrfs_print_leaf(root, path->nodes[0]);
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 1f157fba8940..510cad48e519 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -751,7 +751,12 @@ int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs,
        fs_devs->fsid_kobj.kset = btrfs_kset;
        error = kobject_init_and_add(&fs_devs->fsid_kobj,
                                &btrfs_ktype, parent, "%pU", fs_devs->fsid);
-       return error;
+       if (error) {
+               kobject_put(&fs_devs->fsid_kobj);
+               return error;
+       }
+
+       return 0;
 }
 
 int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
diff --git a/fs/char_dev.c b/fs/char_dev.c
index 44a240c4bb65..a112a4745d8b 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -134,6 +134,12 @@ __register_chrdev_region(unsigned int major, unsigned int 
baseminor,
                        ret = -EBUSY;
                        goto out;
                }
+
+               if (new_min < old_min && new_max > old_max) {
+                       ret = -EBUSY;
+                       goto out;
+               }
+
        }
 
        cd->next = *cp;
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 4815be26b15f..b8046182efb0 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -5223,7 +5223,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr 
*attr)
                        up_write(&EXT4_I(inode)->i_data_sem);
                        ext4_journal_stop(handle);
                        if (error) {
-                               if (orphan)
+                               if (orphan && inode->i_nlink)
                                        ext4_orphan_del(NULL, inode);
                                goto err_out;
                        }
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 7a8b1d72e3d9..efd44d5645d8 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -136,22 +136,26 @@ static int demote_ok(const struct gfs2_glock *gl)
 
 void gfs2_glock_add_to_lru(struct gfs2_glock *gl)
 {
+       if (!(gl->gl_ops->go_flags & GLOF_LRU))
+               return;
+
        spin_lock(&lru_lock);
 
-       if (!list_empty(&gl->gl_lru))
-               list_del_init(&gl->gl_lru);
-       else
+       list_del(&gl->gl_lru);
+       list_add_tail(&gl->gl_lru, &lru_list);
+
+       if (!test_bit(GLF_LRU, &gl->gl_flags)) {
+               set_bit(GLF_LRU, &gl->gl_flags);
                atomic_inc(&lru_count);
+       }
 
-       list_add_tail(&gl->gl_lru, &lru_list);
-       set_bit(GLF_LRU, &gl->gl_flags);
        spin_unlock(&lru_lock);
 }
 
 static void gfs2_glock_remove_from_lru(struct gfs2_glock *gl)
 {
        spin_lock(&lru_lock);
-       if (!list_empty(&gl->gl_lru)) {
+       if (test_bit(GLF_LRU, &gl->gl_flags)) {
                list_del_init(&gl->gl_lru);
                atomic_dec(&lru_count);
                clear_bit(GLF_LRU, &gl->gl_flags);
@@ -1048,8 +1052,7 @@ void gfs2_glock_dq(struct gfs2_holder *gh)
                    !test_bit(GLF_DEMOTE, &gl->gl_flags))
                        fast_path = 1;
        }
-       if (!test_bit(GLF_LFLUSH, &gl->gl_flags) && demote_ok(gl) &&
-           (glops->go_flags & GLOF_LRU))
+       if (!test_bit(GLF_LFLUSH, &gl->gl_flags) && demote_ok(gl))
                gfs2_glock_add_to_lru(gl);
 
        trace_gfs2_glock_queue(gh, 0);
@@ -1349,6 +1352,7 @@ __acquires(&lru_lock)
                if (!spin_trylock(&gl->gl_lockref.lock)) {
 add_back_to_lru:
                        list_add(&gl->gl_lru, &lru_list);
+                       set_bit(GLF_LRU, &gl->gl_flags);
                        atomic_inc(&lru_count);
                        continue;
                }
@@ -1356,7 +1360,6 @@ __acquires(&lru_lock)
                        spin_unlock(&gl->gl_lockref.lock);
                        goto add_back_to_lru;
                }
-               clear_bit(GLF_LRU, &gl->gl_flags);
                gl->gl_lockref.count++;
                if (demote_ok(gl))
                        handle_callback(gl, LM_ST_UNLOCKED, 0, false);
@@ -1392,6 +1395,7 @@ static long gfs2_scan_glock_lru(int nr)
                if (!test_bit(GLF_LOCK, &gl->gl_flags)) {
                        list_move(&gl->gl_lru, &dispose);
                        atomic_dec(&lru_count);
+                       clear_bit(GLF_LRU, &gl->gl_flags);
                        freed++;
                        continue;
                }
diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c
index 8b907c5cc913..3c3d037df824 100644
--- a/fs/gfs2/lock_dlm.c
+++ b/fs/gfs2/lock_dlm.c
@@ -32,9 +32,10 @@ extern struct workqueue_struct *gfs2_control_wq;
  * @delta is the difference between the current rtt sample and the
  * running average srtt. We add 1/8 of that to the srtt in order to
  * update the current srtt estimate. The variance estimate is a bit
- * more complicated. We subtract the abs value of the @delta from
- * the current variance estimate and add 1/4 of that to the running
- * total.
+ * more complicated. We subtract the current variance estimate from
+ * the abs value of the @delta and add 1/4 of that to the running
+ * total.  That's equivalent to 3/4 of the current variance
+ * estimate plus 1/4 of the abs of @delta.
  *
  * Note that the index points at the array entry containing the smoothed
  * mean value, and the variance is always in the following entry
@@ -50,7 +51,7 @@ static inline void gfs2_update_stats(struct gfs2_lkstats *s, 
unsigned index,
        s64 delta = sample - s->stats[index];
        s->stats[index] += (delta >> 3);
        index++;
-       s->stats[index] += ((abs(delta) - s->stats[index]) >> 2);
+       s->stats[index] += (s64)(abs(delta) - s->stats[index]) >> 2;
 }
 
 /**
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 4acc677ac8fb..253b03451b72 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -451,9 +451,7 @@ static void remove_inode_hugepages(struct inode *inode, 
loff_t lstart,
                        if (next >= end)
                                break;
 
-                       hash = hugetlb_fault_mutex_hash(h, current->mm,
-                                                       &pseudo_vma,
-                                                       mapping, next, 0);
+                       hash = hugetlb_fault_mutex_hash(h, mapping, next, 0);
                        mutex_lock(&hugetlb_fault_mutex_table[hash]);
 
                        /*
@@ -573,7 +571,6 @@ static long hugetlbfs_fallocate(struct file *file, int 
mode, loff_t offset,
        struct address_space *mapping = inode->i_mapping;
        struct hstate *h = hstate_inode(inode);
        struct vm_area_struct pseudo_vma;
-       struct mm_struct *mm = current->mm;
        loff_t hpage_size = huge_page_size(h);
        unsigned long hpage_shift = huge_page_shift(h);
        pgoff_t start, index, end;
@@ -637,8 +634,7 @@ static long hugetlbfs_fallocate(struct file *file, int 
mode, loff_t offset,
                addr = index * hpage_size;
 
                /* mutex taken here, fault path and hole punch */
-               hash = hugetlb_fault_mutex_hash(h, mm, &pseudo_vma, mapping,
-                                               index, addr);
+               hash = hugetlb_fault_mutex_hash(h, mapping, index, addr);
                mutex_lock(&hugetlb_fault_mutex_table[hash]);
 
                /* See if already present in mapping to avoid alloc/free */
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 97cb48f03dc7..a5ca6f199b88 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -237,7 +237,7 @@ static inline void bio_cnt_set(struct bio *bio, unsigned 
int count)
 {
        if (count != 1) {
                bio->bi_flags |= (1 << BIO_REFFED);
-               smp_mb__before_atomic();
+               smp_mb();
        }
        atomic_set(&bio->__bi_cnt, count);
 }
diff --git a/include/linux/hid.h b/include/linux/hid.h
index fab65b61d6d4..04bdf5477ec5 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -374,6 +374,7 @@ struct hid_global {
 
 struct hid_local {
        unsigned usage[HID_MAX_USAGES]; /* usage array */
+       u8 usage_size[HID_MAX_USAGES]; /* usage size array */
        unsigned collection_index[HID_MAX_USAGES]; /* collection index array */
        unsigned usage_index;
        unsigned usage_minimum;
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index b699d59d0f4f..6b8a7b654771 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -92,9 +92,7 @@ void putback_active_hugepage(struct page *page);
 void free_huge_page(struct page *page);
 void hugetlb_fix_reserve_counts(struct inode *inode);
 extern struct mutex *hugetlb_fault_mutex_table;
-u32 hugetlb_fault_mutex_hash(struct hstate *h, struct mm_struct *mm,
-                               struct vm_area_struct *vma,
-                               struct address_space *mapping,
+u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping,
                                pgoff_t idx, unsigned long address);
 
 pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud);
diff --git a/include/linux/iio/adc/ad_sigma_delta.h 
b/include/linux/iio/adc/ad_sigma_delta.h
index 6cc48ac55fd2..40b14736c73d 100644
--- a/include/linux/iio/adc/ad_sigma_delta.h
+++ b/include/linux/iio/adc/ad_sigma_delta.h
@@ -66,6 +66,7 @@ struct ad_sigma_delta {
        bool                    irq_dis;
 
        bool                    bus_locked;
+       bool                    keep_cs_asserted;
 
        uint8_t                 comm;
 
diff --git a/include/linux/smpboot.h b/include/linux/smpboot.h
index 12910cf19869..12a4b09f4d08 100644
--- a/include/linux/smpboot.h
+++ b/include/linux/smpboot.h
@@ -30,7 +30,7 @@ struct smpboot_thread_data;
  * @thread_comm:       The base name of the thread
  */
 struct smp_hotplug_thread {
-       struct task_struct __percpu     **store;
+       struct task_struct              * __percpu *store;
        struct list_head                list;
        int                             (*thread_should_run)(unsigned int cpu);
        void                            (*thread_fn)(unsigned int cpu);
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index cd4f41397c7e..42b7251c597f 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -1095,22 +1095,24 @@ int audit_rule_change(int type, __u32 portid, int seq, 
void *data,
        int err = 0;
        struct audit_entry *entry;
 
-       entry = audit_data_to_entry(data, datasz);
-       if (IS_ERR(entry))
-               return PTR_ERR(entry);
-
        switch (type) {
        case AUDIT_ADD_RULE:
+               entry = audit_data_to_entry(data, datasz);
+               if (IS_ERR(entry))
+                       return PTR_ERR(entry);
                err = audit_add_rule(entry);
                audit_log_rule_change("add_rule", &entry->rule, !err);
                break;
        case AUDIT_DEL_RULE:
+               entry = audit_data_to_entry(data, datasz);
+               if (IS_ERR(entry))
+                       return PTR_ERR(entry);
                err = audit_del_rule(entry);
                audit_log_rule_change("remove_rule", &entry->rule, !err);
                break;
        default:
-               err = -EINVAL;
                WARN_ON(1);
+               return -EINVAL;
        }
 
        if (err || type == AUDIT_DEL_RULE) {
diff --git a/kernel/rcu/rcuperf.c b/kernel/rcu/rcuperf.c
index 123ccbd22449..2b8579d5a544 100644
--- a/kernel/rcu/rcuperf.c
+++ b/kernel/rcu/rcuperf.c
@@ -453,6 +453,10 @@ rcu_perf_cleanup(void)
 
        if (torture_cleanup_begin())
                return;
+       if (!cur_ops) {
+               torture_cleanup_end();
+               return;
+       }
 
        if (reader_tasks) {
                for (i = 0; i < nrealreaders; i++)
@@ -574,6 +578,7 @@ rcu_perf_init(void)
                        pr_alert(" %s", perf_ops[i]->name);
                pr_alert("\n");
                firsterr = -EINVAL;
+               cur_ops = NULL;
                goto unwind;
        }
        if (cur_ops->init)
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index bf08fee53dc7..5393bbcf3c1a 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -1595,6 +1595,10 @@ rcu_torture_cleanup(void)
                        cur_ops->cb_barrier();
                return;
        }
+       if (!cur_ops) {
+               torture_cleanup_end();
+               return;
+       }
 
        rcu_torture_barrier_cleanup();
        torture_stop_kthread(rcu_torture_stall, stall_task);
@@ -1730,6 +1734,7 @@ rcu_torture_init(void)
                        pr_alert(" %s", torture_ops[i]->name);
                pr_alert("\n");
                firsterr = -EINVAL;
+               cur_ops = NULL;
                goto unwind;
        }
        if (cur_ops->fqs == NULL && fqs_duration != 0) {
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 50e80b1be2c8..3861dd6da91e 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -8512,6 +8512,8 @@ static void cpu_cgroup_attach(struct cgroup_taskset *tset)
 static int cpu_shares_write_u64(struct cgroup_subsys_state *css,
                                struct cftype *cftype, u64 shareval)
 {
+       if (shareval > scale_load_down(ULONG_MAX))
+               shareval = MAX_SHARES;
        return sched_group_set_shares(css_tg(css), scale_load(shareval));
 }
 
@@ -8611,8 +8613,10 @@ int tg_set_cfs_quota(struct task_group *tg, long 
cfs_quota_us)
        period = ktime_to_ns(tg->cfs_bandwidth.period);
        if (cfs_quota_us < 0)
                quota = RUNTIME_INF;
-       else
+       else if ((u64)cfs_quota_us <= U64_MAX / NSEC_PER_USEC)
                quota = (u64)cfs_quota_us * NSEC_PER_USEC;
+       else
+               return -EINVAL;
 
        return tg_set_cfs_bandwidth(tg, period, quota);
 }
@@ -8634,6 +8638,9 @@ int tg_set_cfs_period(struct task_group *tg, long 
cfs_period_us)
 {
        u64 quota, period;
 
+       if ((u64)cfs_period_us > U64_MAX / NSEC_PER_USEC)
+               return -EINVAL;
+
        period = (u64)cfs_period_us * NSEC_PER_USEC;
        quota = tg->cfs_bandwidth.quota;
 
diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
index 7e35fc450c5b..5a07f19059c3 100644
--- a/lib/strncpy_from_user.c
+++ b/lib/strncpy_from_user.c
@@ -22,10 +22,11 @@
  * hit it), 'max' is the address space maximum (and we return
  * -EFAULT if we hit it).
  */
-static inline long do_strncpy_from_user(char *dst, const char __user *src, 
long count, unsigned long max)
+static inline long do_strncpy_from_user(char *dst, const char __user *src,
+                                       unsigned long count, unsigned long max)
 {
        const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
-       long res = 0;
+       unsigned long res = 0;
 
        /*
         * Truncate 'max' to the user-specified limit, so that
diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
index 8e105ed4df12..9ff4f3bbb1aa 100644
--- a/lib/strnlen_user.c
+++ b/lib/strnlen_user.c
@@ -27,7 +27,7 @@
 static inline long do_strnlen_user(const char __user *src, unsigned long 
count, unsigned long max)
 {
        const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
-       long align, res = 0;
+       unsigned long align, res = 0;
        unsigned long c;
 
        /*
@@ -41,7 +41,7 @@ static inline long do_strnlen_user(const char __user *src, 
unsigned long count,
         * Do everything aligned. But that means that we
         * need to also expand the maximum..
         */
-       align = (sizeof(long) - 1) & (unsigned long)src;
+       align = (sizeof(unsigned long) - 1) & (unsigned long)src;
        src -= align;
        max += align;
 
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 8b682da98d95..75d8bd7e8798 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3812,21 +3812,14 @@ static int hugetlb_no_page(struct mm_struct *mm, struct 
vm_area_struct *vma,
 }
 
 #ifdef CONFIG_SMP
-u32 hugetlb_fault_mutex_hash(struct hstate *h, struct mm_struct *mm,
-                           struct vm_area_struct *vma,
-                           struct address_space *mapping,
+u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping,
                            pgoff_t idx, unsigned long address)
 {
        unsigned long key[2];
        u32 hash;
 
-       if (vma->vm_flags & VM_SHARED) {
-               key[0] = (unsigned long) mapping;
-               key[1] = idx;
-       } else {
-               key[0] = (unsigned long) mm;
-               key[1] = address >> huge_page_shift(h);
-       }
+       key[0] = (unsigned long) mapping;
+       key[1] = idx;
 
        hash = jhash2((u32 *)&key, sizeof(key)/sizeof(u32), 0);
 
@@ -3837,9 +3830,7 @@ u32 hugetlb_fault_mutex_hash(struct hstate *h, struct 
mm_struct *mm,
  * For uniprocesor systems we always use a single mutex, so just
  * return 0 and avoid the hashing overhead.
  */
-u32 hugetlb_fault_mutex_hash(struct hstate *h, struct mm_struct *mm,
-                           struct vm_area_struct *vma,
-                           struct address_space *mapping,
+u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping,
                            pgoff_t idx, unsigned long address)
 {
        return 0;
@@ -3885,7 +3876,7 @@ int hugetlb_fault(struct mm_struct *mm, struct 
vm_area_struct *vma,
         * get spurious allocation failures if two CPUs race to instantiate
         * the same page in the page cache.
         */
-       hash = hugetlb_fault_mutex_hash(h, mm, vma, mapping, idx, address);
+       hash = hugetlb_fault_mutex_hash(h, mapping, idx, address);
        mutex_lock(&hugetlb_fault_mutex_table[hash]);
 
        entry = huge_ptep_get(ptep);
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 6e0aa296f134..d787717140e5 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -1072,9 +1072,6 @@ static void ieee80211_chswitch_work(struct work_struct 
*work)
                goto out;
        }
 
-       /* XXX: shouldn't really modify cfg80211-owned data! */
-       ifmgd->associated->channel = sdata->csa_chandef.chan;
-
        ifmgd->csa_waiting_bcn = true;
 
        ieee80211_sta_reset_beacon_monitor(sdata);
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 09a353c6373a..d6e629315771 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -14014,6 +14014,11 @@ void cfg80211_ch_switch_notify(struct net_device *dev,
 
        wdev->chandef = *chandef;
        wdev->preset_chandef = *chandef;
+
+       if (wdev->iftype == NL80211_IFTYPE_STATION &&
+           !WARN_ON(!wdev->current_bss))
+               wdev->current_bss->pub.channel = chandef->chan;
+
        nl80211_ch_switch_notify(rdev, dev, chandef, GFP_KERNEL,
                                 NL80211_CMD_CH_SWITCH_NOTIFY, 0);
 }
diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index 90b5948e0ff3..cba5b5a29da0 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -137,8 +137,12 @@ static int hdmi_codec_startup(struct snd_pcm_substream 
*substream,
                if (!ret) {
                        ret = snd_pcm_hw_constraint_eld(substream->runtime,
                                                        hcp->eld);
-                       if (ret)
+                       if (ret) {
+                               mutex_lock(&hcp->current_stream_lock);
+                               hcp->current_stream = NULL;
+                               mutex_unlock(&hcp->current_stream_lock);
                                return ret;
+                       }
                }
        }
        return 0;
diff --git a/sound/soc/davinci/davinci-mcasp.c 
b/sound/soc/davinci/davinci-mcasp.c
index 3c5a9804d3f5..5a0b17ebfc02 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -43,6 +43,7 @@
 
 #define MCASP_MAX_AFIFO_DEPTH  64
 
+#ifdef CONFIG_PM
 static u32 context_regs[] = {
        DAVINCI_MCASP_TXFMCTL_REG,
        DAVINCI_MCASP_RXFMCTL_REG,
@@ -65,6 +66,7 @@ struct davinci_mcasp_context {
        u32     *xrsr_regs; /* for serializer configuration */
        bool    pm_state;
 };
+#endif
 
 struct davinci_mcasp_ruledata {
        struct davinci_mcasp *mcasp;
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index a732b3a065c9..8a2873a7899a 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -172,16 +172,17 @@ config SND_MPC52xx_SOC_EFIKA
 
 endif # SND_POWERPC_SOC
 
+config SND_SOC_IMX_PCM_FIQ
+       tristate
+       default y if SND_SOC_IMX_SSI=y && (SND_SOC_FSL_SSI=m || 
SND_SOC_FSL_SPDIF=m) && (MXC_TZIC || MXC_AVIC)
+       select FIQ
+
 if SND_IMX_SOC
 
 config SND_SOC_IMX_SSI
        tristate
        select SND_SOC_FSL_UTILS
 
-config SND_SOC_IMX_PCM_FIQ
-       tristate
-       select FIQ
-
 comment "SoC Audio support for Freescale i.MX boards:"
 
 config SND_MXC_SOC_WM1133_EV1
diff --git a/sound/soc/fsl/eukrea-tlv320.c b/sound/soc/fsl/eukrea-tlv320.c
index 883087f2b092..38132143b7d5 100644
--- a/sound/soc/fsl/eukrea-tlv320.c
+++ b/sound/soc/fsl/eukrea-tlv320.c
@@ -119,13 +119,13 @@ static int eukrea_tlv320_probe(struct platform_device 
*pdev)
                if (ret) {
                        dev_err(&pdev->dev,
                                "fsl,mux-int-port node missing or invalid.\n");
-                       return ret;
+                       goto err;
                }
                ret = of_property_read_u32(np, "fsl,mux-ext-port", &ext_port);
                if (ret) {
                        dev_err(&pdev->dev,
                                "fsl,mux-ext-port node missing or invalid.\n");
-                       return ret;
+                       goto err;
                }
 
                /*
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index 9fadf7e31c5f..cb43f57f978b 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -274,12 +274,14 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai 
*cpu_dai,
        case SND_SOC_DAIFMT_CBS_CFS:
                val_cr2 |= FSL_SAI_CR2_BCD_MSTR;
                val_cr4 |= FSL_SAI_CR4_FSD_MSTR;
+               sai->is_slave_mode = false;
                break;
        case SND_SOC_DAIFMT_CBM_CFM:
                sai->is_slave_mode = true;
                break;
        case SND_SOC_DAIFMT_CBS_CFM:
                val_cr2 |= FSL_SAI_CR2_BCD_MSTR;
+               sai->is_slave_mode = false;
                break;
        case SND_SOC_DAIFMT_CBM_CFS:
                val_cr4 |= FSL_SAI_CR4_FSD_MSTR;
diff --git a/sound/soc/fsl/fsl_utils.c b/sound/soc/fsl/fsl_utils.c
index b9e42b503a37..4f8bdb7650e8 100644
--- a/sound/soc/fsl/fsl_utils.c
+++ b/sound/soc/fsl/fsl_utils.c
@@ -75,6 +75,7 @@ int fsl_asoc_get_dma_channel(struct device_node *ssi_np,
        iprop = of_get_property(dma_np, "cell-index", NULL);
        if (!iprop) {
                of_node_put(dma_np);
+               of_node_put(dma_channel_np);
                return -EINVAL;
        }
        *dma_id = be32_to_cpup(iprop);
diff --git a/tools/include/linux/bitops.h b/tools/include/linux/bitops.h
index fc446343ff41..7e3b87a77334 100644
--- a/tools/include/linux/bitops.h
+++ b/tools/include/linux/bitops.h
@@ -3,8 +3,6 @@
 
 #include <asm/types.h>
 #include <linux/kernel.h>
-#include <linux/compiler.h>
-
 #ifndef __WORDSIZE
 #define __WORDSIZE (__SIZEOF_LONG__ * 8)
 #endif
@@ -12,10 +10,9 @@
 #ifndef BITS_PER_LONG
 # define BITS_PER_LONG __WORDSIZE
 #endif
+#include <linux/bits.h>
+#include <linux/compiler.h>
 
-#define BIT_MASK(nr)           (1UL << ((nr) % BITS_PER_LONG))
-#define BIT_WORD(nr)           ((nr) / BITS_PER_LONG)
-#define BITS_PER_BYTE          8
 #define BITS_TO_LONGS(nr)      DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
 #define BITS_TO_U64(nr)                DIV_ROUND_UP(nr, BITS_PER_BYTE * 
sizeof(u64))
 #define BITS_TO_U32(nr)                DIV_ROUND_UP(nr, BITS_PER_BYTE * 
sizeof(u32))
diff --git a/tools/include/linux/bits.h b/tools/include/linux/bits.h
new file mode 100644
index 000000000000..2b7b532c1d51
--- /dev/null
+++ b/tools/include/linux/bits.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __LINUX_BITS_H
+#define __LINUX_BITS_H
+#include <asm/bitsperlong.h>
+
+#define BIT(nr)                        (1UL << (nr))
+#define BIT_ULL(nr)            (1ULL << (nr))
+#define BIT_MASK(nr)           (1UL << ((nr) % BITS_PER_LONG))
+#define BIT_WORD(nr)           ((nr) / BITS_PER_LONG)
+#define BIT_ULL_MASK(nr)       (1ULL << ((nr) % BITS_PER_LONG_LONG))
+#define BIT_ULL_WORD(nr)       ((nr) / BITS_PER_LONG_LONG)
+#define BITS_PER_BYTE          8
+
+/*
+ * Create a contiguous bitmask starting at bit position @l and ending at
+ * position @h. For example
+ * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
+ */
+#define GENMASK(h, l) \
+       (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+
+#define GENMASK_ULL(h, l) \
+       (((~0ULL) - (1ULL << (l)) + 1) & \
+        (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
+
+#endif /* __LINUX_BITS_H */
diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh
index 83fe2202382e..ff38fc63bceb 100755
--- a/tools/perf/check-headers.sh
+++ b/tools/perf/check-headers.sh
@@ -4,6 +4,7 @@ HEADERS='
 include/uapi/linux/fcntl.h
 include/uapi/linux/perf_event.h
 include/uapi/linux/stat.h
+include/linux/bits.h
 include/linux/hash.h
 include/uapi/linux/hw_breakpoint.h
 arch/x86/include/asm/disabled-features.h
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index e72d370889f8..8b39e8086c2d 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -74,7 +74,6 @@
 #include <sys/ttydefaults.h>
 #include <api/fs/tracing_path.h>
 #include <termios.h>
-#include <linux/bitops.h>
 #include <termios.h>
 #include "strlist.h"
 

Reply via email to