Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.14 commit in: /
Date: Fri, 31 May 2019 16:41:34
Message-Id: 1559320867.44ac09cc56d587cf3dce78163ce613230680c0aa.mpagano@gentoo
1 commit: 44ac09cc56d587cf3dce78163ce613230680c0aa
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Fri May 31 16:41:07 2019 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Fri May 31 16:41:07 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=44ac09cc
7
8 Linux patch 4.14.123
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1122_linux-4.14.123.patch | 5631 +++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 5635 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index ac52010..81872ea 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -531,6 +531,10 @@ Patch: 1121_4.14.122.patch
21 From: http://www.kernel.org
22 Desc: Linux 4.14.122
23
24 +Patch: 1122_4.14.123.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 4.14.123
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1122_linux-4.14.123.patch b/1122_linux-4.14.123.patch
33 new file mode 100644
34 index 0000000..504bbf4
35 --- /dev/null
36 +++ b/1122_linux-4.14.123.patch
37 @@ -0,0 +1,5631 @@
38 +diff --git a/Makefile b/Makefile
39 +index 0c4424292649..a8e8a53cc08b 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,7 +1,7 @@
43 + # SPDX-License-Identifier: GPL-2.0
44 + VERSION = 4
45 + PATCHLEVEL = 14
46 +-SUBLEVEL = 122
47 ++SUBLEVEL = 123
48 + EXTRAVERSION =
49 + NAME = Petit Gorille
50 +
51 +diff --git a/arch/arm/include/asm/cp15.h b/arch/arm/include/asm/cp15.h
52 +index 07e27f212dc7..d2453e2d3f1f 100644
53 +--- a/arch/arm/include/asm/cp15.h
54 ++++ b/arch/arm/include/asm/cp15.h
55 +@@ -68,6 +68,8 @@
56 + #define BPIALL __ACCESS_CP15(c7, 0, c5, 6)
57 + #define ICIALLU __ACCESS_CP15(c7, 0, c5, 0)
58 +
59 ++#define CNTVCT __ACCESS_CP15_64(1, c14)
60 ++
61 + extern unsigned long cr_alignment; /* defined in entry-armv.S */
62 +
63 + static inline unsigned long get_cr(void)
64 +diff --git a/arch/arm/vdso/vgettimeofday.c b/arch/arm/vdso/vgettimeofday.c
65 +index 79214d5ff097..3af02d2a0b7f 100644
66 +--- a/arch/arm/vdso/vgettimeofday.c
67 ++++ b/arch/arm/vdso/vgettimeofday.c
68 +@@ -18,9 +18,9 @@
69 + #include <linux/compiler.h>
70 + #include <linux/hrtimer.h>
71 + #include <linux/time.h>
72 +-#include <asm/arch_timer.h>
73 + #include <asm/barrier.h>
74 + #include <asm/bug.h>
75 ++#include <asm/cp15.h>
76 + #include <asm/page.h>
77 + #include <asm/unistd.h>
78 + #include <asm/vdso_datapage.h>
79 +@@ -123,7 +123,8 @@ static notrace u64 get_ns(struct vdso_data *vdata)
80 + u64 cycle_now;
81 + u64 nsec;
82 +
83 +- cycle_now = arch_counter_get_cntvct();
84 ++ isb();
85 ++ cycle_now = read_sysreg(CNTVCT);
86 +
87 + cycle_delta = (cycle_now - vdata->cs_cycle_last) & vdata->cs_mask;
88 +
89 +diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
90 +index aafea648a30f..ee77556b0124 100644
91 +--- a/arch/arm64/include/asm/pgtable.h
92 ++++ b/arch/arm64/include/asm/pgtable.h
93 +@@ -420,6 +420,8 @@ static inline phys_addr_t pmd_page_paddr(pmd_t pmd)
94 + return pmd_val(pmd) & PHYS_MASK & (s32)PAGE_MASK;
95 + }
96 +
97 ++static inline void pte_unmap(pte_t *pte) { }
98 ++
99 + /* Find an entry in the third-level page table. */
100 + #define pte_index(addr) (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
101 +
102 +@@ -428,7 +430,6 @@ static inline phys_addr_t pmd_page_paddr(pmd_t pmd)
103 +
104 + #define pte_offset_map(dir,addr) pte_offset_kernel((dir), (addr))
105 + #define pte_offset_map_nested(dir,addr) pte_offset_kernel((dir), (addr))
106 +-#define pte_unmap(pte) do { } while (0)
107 + #define pte_unmap_nested(pte) do { } while (0)
108 +
109 + #define pte_set_fixmap(addr) ((pte_t *)set_fixmap_offset(FIX_PTE, addr))
110 +diff --git a/arch/arm64/include/asm/vdso_datapage.h b/arch/arm64/include/asm/vdso_datapage.h
111 +index 2b9a63771eda..f89263c8e11a 100644
112 +--- a/arch/arm64/include/asm/vdso_datapage.h
113 ++++ b/arch/arm64/include/asm/vdso_datapage.h
114 +@@ -38,6 +38,7 @@ struct vdso_data {
115 + __u32 tz_minuteswest; /* Whacky timezone stuff */
116 + __u32 tz_dsttime;
117 + __u32 use_syscall;
118 ++ __u32 hrtimer_res;
119 + };
120 +
121 + #endif /* !__ASSEMBLY__ */
122 +diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c
123 +index b5e43b01b396..b4a0f4ab770a 100644
124 +--- a/arch/arm64/kernel/asm-offsets.c
125 ++++ b/arch/arm64/kernel/asm-offsets.c
126 +@@ -95,7 +95,7 @@ int main(void)
127 + DEFINE(CLOCK_REALTIME, CLOCK_REALTIME);
128 + DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC);
129 + DEFINE(CLOCK_MONOTONIC_RAW, CLOCK_MONOTONIC_RAW);
130 +- DEFINE(CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC);
131 ++ DEFINE(CLOCK_REALTIME_RES, offsetof(struct vdso_data, hrtimer_res));
132 + DEFINE(CLOCK_REALTIME_COARSE, CLOCK_REALTIME_COARSE);
133 + DEFINE(CLOCK_MONOTONIC_COARSE,CLOCK_MONOTONIC_COARSE);
134 + DEFINE(CLOCK_COARSE_RES, LOW_RES_NSEC);
135 +diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c
136 +index d16978213c5b..e2a9d04d0517 100644
137 +--- a/arch/arm64/kernel/cpu_ops.c
138 ++++ b/arch/arm64/kernel/cpu_ops.c
139 +@@ -85,6 +85,7 @@ static const char *__init cpu_read_enable_method(int cpu)
140 + pr_err("%pOF: missing enable-method property\n",
141 + dn);
142 + }
143 ++ of_node_put(dn);
144 + } else {
145 + enable_method = acpi_get_enable_method(cpu);
146 + if (!enable_method) {
147 +diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
148 +index 2d419006ad43..ec0bb588d755 100644
149 +--- a/arch/arm64/kernel/vdso.c
150 ++++ b/arch/arm64/kernel/vdso.c
151 +@@ -232,6 +232,9 @@ void update_vsyscall(struct timekeeper *tk)
152 + vdso_data->wtm_clock_sec = tk->wall_to_monotonic.tv_sec;
153 + vdso_data->wtm_clock_nsec = tk->wall_to_monotonic.tv_nsec;
154 +
155 ++ /* Read without the seqlock held by clock_getres() */
156 ++ WRITE_ONCE(vdso_data->hrtimer_res, hrtimer_resolution);
157 ++
158 + if (!use_syscall) {
159 + /* tkr_mono.cycle_last == tkr_raw.cycle_last */
160 + vdso_data->cs_cycle_last = tk->tkr_mono.cycle_last;
161 +diff --git a/arch/arm64/kernel/vdso/gettimeofday.S b/arch/arm64/kernel/vdso/gettimeofday.S
162 +index 76320e920965..df829c4346fa 100644
163 +--- a/arch/arm64/kernel/vdso/gettimeofday.S
164 ++++ b/arch/arm64/kernel/vdso/gettimeofday.S
165 +@@ -301,13 +301,14 @@ ENTRY(__kernel_clock_getres)
166 + ccmp w0, #CLOCK_MONOTONIC_RAW, #0x4, ne
167 + b.ne 1f
168 +
169 +- ldr x2, 5f
170 ++ adr vdso_data, _vdso_data
171 ++ ldr w2, [vdso_data, #CLOCK_REALTIME_RES]
172 + b 2f
173 + 1:
174 + cmp w0, #CLOCK_REALTIME_COARSE
175 + ccmp w0, #CLOCK_MONOTONIC_COARSE, #0x4, ne
176 + b.ne 4f
177 +- ldr x2, 6f
178 ++ ldr x2, 5f
179 + 2:
180 + cbz w1, 3f
181 + stp xzr, x2, [x1]
182 +@@ -321,8 +322,6 @@ ENTRY(__kernel_clock_getres)
183 + svc #0
184 + ret
185 + 5:
186 +- .quad CLOCK_REALTIME_RES
187 +-6:
188 + .quad CLOCK_COARSE_RES
189 + .cfi_endproc
190 + ENDPROC(__kernel_clock_getres)
191 +diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
192 +index ba88b5b68db6..56c110844c01 100644
193 +--- a/arch/arm64/mm/dma-mapping.c
194 ++++ b/arch/arm64/mm/dma-mapping.c
195 +@@ -710,6 +710,11 @@ static int __iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
196 + if (dma_mmap_from_dev_coherent(dev, vma, cpu_addr, size, &ret))
197 + return ret;
198 +
199 ++ if (!is_vmalloc_addr(cpu_addr)) {
200 ++ unsigned long pfn = page_to_pfn(virt_to_page(cpu_addr));
201 ++ return __swiotlb_mmap_pfn(vma, pfn, size);
202 ++ }
203 ++
204 + if (attrs & DMA_ATTR_FORCE_CONTIGUOUS) {
205 + /*
206 + * DMA_ATTR_FORCE_CONTIGUOUS allocations are always remapped,
207 +@@ -733,6 +738,11 @@ static int __iommu_get_sgtable(struct device *dev, struct sg_table *sgt,
208 + unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
209 + struct vm_struct *area = find_vm_area(cpu_addr);
210 +
211 ++ if (!is_vmalloc_addr(cpu_addr)) {
212 ++ struct page *page = virt_to_page(cpu_addr);
213 ++ return __swiotlb_get_sgtable_page(sgt, page, size);
214 ++ }
215 ++
216 + if (attrs & DMA_ATTR_FORCE_CONTIGUOUS) {
217 + /*
218 + * DMA_ATTR_FORCE_CONTIGUOUS allocations are always remapped,
219 +diff --git a/arch/powerpc/boot/addnote.c b/arch/powerpc/boot/addnote.c
220 +index 9d9f6f334d3c..3da3e2b1b51b 100644
221 +--- a/arch/powerpc/boot/addnote.c
222 ++++ b/arch/powerpc/boot/addnote.c
223 +@@ -223,7 +223,11 @@ main(int ac, char **av)
224 + PUT_16(E_PHNUM, np + 2);
225 +
226 + /* write back */
227 +- lseek(fd, (long) 0, SEEK_SET);
228 ++ i = lseek(fd, (long) 0, SEEK_SET);
229 ++ if (i < 0) {
230 ++ perror("lseek");
231 ++ exit(1);
232 ++ }
233 + i = write(fd, buf, n);
234 + if (i < 0) {
235 + perror("write");
236 +diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
237 +index ff8511d6d8ea..4f2e18266e34 100644
238 +--- a/arch/powerpc/kernel/head_64.S
239 ++++ b/arch/powerpc/kernel/head_64.S
240 +@@ -961,7 +961,9 @@ start_here_multiplatform:
241 +
242 + /* Restore parameters passed from prom_init/kexec */
243 + mr r3,r31
244 +- bl early_setup /* also sets r13 and SPRG_PACA */
245 ++ LOAD_REG_ADDR(r12, DOTSYM(early_setup))
246 ++ mtctr r12
247 ++ bctrl /* also sets r13 and SPRG_PACA */
248 +
249 + LOAD_REG_ADDR(r3, start_here_common)
250 + ld r4,PACAKMSR(r13)
251 +diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
252 +index 0a02c73a27b3..417ea6db7b1d 100644
253 +--- a/arch/powerpc/mm/numa.c
254 ++++ b/arch/powerpc/mm/numa.c
255 +@@ -1561,6 +1561,9 @@ int start_topology_update(void)
256 + {
257 + int rc = 0;
258 +
259 ++ if (!topology_updates_enabled)
260 ++ return 0;
261 ++
262 + if (firmware_has_feature(FW_FEATURE_PRRN)) {
263 + if (!prrn_enabled) {
264 + prrn_enabled = 1;
265 +@@ -1590,6 +1593,9 @@ int stop_topology_update(void)
266 + {
267 + int rc = 0;
268 +
269 ++ if (!topology_updates_enabled)
270 ++ return 0;
271 ++
272 + if (prrn_enabled) {
273 + prrn_enabled = 0;
274 + #ifdef CONFIG_SMP
275 +@@ -1635,11 +1641,13 @@ static ssize_t topology_write(struct file *file, const char __user *buf,
276 +
277 + kbuf[read_len] = '\0';
278 +
279 +- if (!strncmp(kbuf, "on", 2))
280 ++ if (!strncmp(kbuf, "on", 2)) {
281 ++ topology_updates_enabled = true;
282 + start_topology_update();
283 +- else if (!strncmp(kbuf, "off", 3))
284 ++ } else if (!strncmp(kbuf, "off", 3)) {
285 + stop_topology_update();
286 +- else
287 ++ topology_updates_enabled = false;
288 ++ } else
289 + return -EINVAL;
290 +
291 + return count;
292 +@@ -1654,9 +1662,7 @@ static const struct file_operations topology_ops = {
293 +
294 + static int topology_update_init(void)
295 + {
296 +- /* Do not poll for changes if disabled at boot */
297 +- if (topology_updates_enabled)
298 +- start_topology_update();
299 ++ start_topology_update();
300 +
301 + if (!proc_create("powerpc/topology_updates", 0644, NULL, &topology_ops))
302 + return -ENOMEM;
303 +diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c
304 +index b73961b95c34..994e4392cac5 100644
305 +--- a/arch/powerpc/perf/imc-pmu.c
306 ++++ b/arch/powerpc/perf/imc-pmu.c
307 +@@ -481,6 +481,11 @@ static int nest_imc_event_init(struct perf_event *event)
308 + * Get the base memory addresss for this cpu.
309 + */
310 + chip_id = cpu_to_chip_id(event->cpu);
311 ++
312 ++ /* Return, if chip_id is not valid */
313 ++ if (chip_id < 0)
314 ++ return -ENODEV;
315 ++
316 + pcni = pmu->mem_info;
317 + do {
318 + if (pcni->id == chip_id) {
319 +diff --git a/arch/x86/Makefile b/arch/x86/Makefile
320 +index eb1f8f249dc3..b4c72da8a7ad 100644
321 +--- a/arch/x86/Makefile
322 ++++ b/arch/x86/Makefile
323 +@@ -48,7 +48,7 @@ export REALMODE_CFLAGS
324 + export BITS
325 +
326 + ifdef CONFIG_X86_NEED_RELOCS
327 +- LDFLAGS_vmlinux := --emit-relocs
328 ++ LDFLAGS_vmlinux := --emit-relocs --discard-none
329 + endif
330 +
331 + #
332 +diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
333 +index 41c671854642..789284d19b55 100644
334 +--- a/arch/x86/ia32/ia32_signal.c
335 ++++ b/arch/x86/ia32/ia32_signal.c
336 +@@ -62,9 +62,8 @@
337 + } while (0)
338 +
339 + #define RELOAD_SEG(seg) { \
340 +- unsigned int pre = GET_SEG(seg); \
341 ++ unsigned int pre = (seg) | 3; \
342 + unsigned int cur = get_user_seg(seg); \
343 +- pre |= 3; \
344 + if (pre != cur) \
345 + set_user_seg(seg, pre); \
346 + }
347 +@@ -73,6 +72,7 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
348 + struct sigcontext_32 __user *sc)
349 + {
350 + unsigned int tmpflags, err = 0;
351 ++ u16 gs, fs, es, ds;
352 + void __user *buf;
353 + u32 tmp;
354 +
355 +@@ -80,16 +80,10 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
356 + current->restart_block.fn = do_no_restart_syscall;
357 +
358 + get_user_try {
359 +- /*
360 +- * Reload fs and gs if they have changed in the signal
361 +- * handler. This does not handle long fs/gs base changes in
362 +- * the handler, but does not clobber them at least in the
363 +- * normal case.
364 +- */
365 +- RELOAD_SEG(gs);
366 +- RELOAD_SEG(fs);
367 +- RELOAD_SEG(ds);
368 +- RELOAD_SEG(es);
369 ++ gs = GET_SEG(gs);
370 ++ fs = GET_SEG(fs);
371 ++ ds = GET_SEG(ds);
372 ++ es = GET_SEG(es);
373 +
374 + COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx);
375 + COPY(dx); COPY(cx); COPY(ip); COPY(ax);
376 +@@ -107,6 +101,17 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
377 + buf = compat_ptr(tmp);
378 + } get_user_catch(err);
379 +
380 ++ /*
381 ++ * Reload fs and gs if they have changed in the signal
382 ++ * handler. This does not handle long fs/gs base changes in
383 ++ * the handler, but does not clobber them at least in the
384 ++ * normal case.
385 ++ */
386 ++ RELOAD_SEG(gs);
387 ++ RELOAD_SEG(fs);
388 ++ RELOAD_SEG(ds);
389 ++ RELOAD_SEG(es);
390 ++
391 + err |= fpu__restore_sig(buf, 1);
392 +
393 + force_iret();
394 +diff --git a/arch/x86/include/asm/text-patching.h b/arch/x86/include/asm/text-patching.h
395 +index ab3b9887e140..12dd61dc3c79 100644
396 +--- a/arch/x86/include/asm/text-patching.h
397 ++++ b/arch/x86/include/asm/text-patching.h
398 +@@ -38,6 +38,7 @@ extern void *text_poke(void *addr, const void *opcode, size_t len);
399 + extern int poke_int3_handler(struct pt_regs *regs);
400 + extern void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler);
401 +
402 ++#ifndef CONFIG_UML_X86
403 + static inline void int3_emulate_jmp(struct pt_regs *regs, unsigned long ip)
404 + {
405 + regs->ip = ip;
406 +@@ -64,6 +65,7 @@ static inline void int3_emulate_call(struct pt_regs *regs, unsigned long func)
407 + int3_emulate_push(regs, regs->ip - INT3_INSN_SIZE + CALL_INSN_SIZE);
408 + int3_emulate_jmp(regs, func);
409 + }
410 +-#endif
411 ++#endif /* CONFIG_X86_64 */
412 ++#endif /* !CONFIG_UML_X86 */
413 +
414 + #endif /* _ASM_X86_TEXT_PATCHING_H */
415 +diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
416 +index 54874e2b1d32..4f3be91f0b0b 100644
417 +--- a/arch/x86/kernel/cpu/mcheck/mce.c
418 ++++ b/arch/x86/kernel/cpu/mcheck/mce.c
419 +@@ -701,19 +701,49 @@ bool machine_check_poll(enum mcp_flags flags, mce_banks_t *b)
420 +
421 + barrier();
422 + m.status = mce_rdmsrl(msr_ops.status(i));
423 ++
424 ++ /* If this entry is not valid, ignore it */
425 + if (!(m.status & MCI_STATUS_VAL))
426 + continue;
427 +
428 + /*
429 +- * Uncorrected or signalled events are handled by the exception
430 +- * handler when it is enabled, so don't process those here.
431 +- *
432 +- * TBD do the same check for MCI_STATUS_EN here?
433 ++ * If we are logging everything (at CPU online) or this
434 ++ * is a corrected error, then we must log it.
435 + */
436 +- if (!(flags & MCP_UC) &&
437 +- (m.status & (mca_cfg.ser ? MCI_STATUS_S : MCI_STATUS_UC)))
438 +- continue;
439 ++ if ((flags & MCP_UC) || !(m.status & MCI_STATUS_UC))
440 ++ goto log_it;
441 ++
442 ++ /*
443 ++ * Newer Intel systems that support software error
444 ++ * recovery need to make additional checks. Other
445 ++ * CPUs should skip over uncorrected errors, but log
446 ++ * everything else.
447 ++ */
448 ++ if (!mca_cfg.ser) {
449 ++ if (m.status & MCI_STATUS_UC)
450 ++ continue;
451 ++ goto log_it;
452 ++ }
453 ++
454 ++ /* Log "not enabled" (speculative) errors */
455 ++ if (!(m.status & MCI_STATUS_EN))
456 ++ goto log_it;
457 ++
458 ++ /*
459 ++ * Log UCNA (SDM: 15.6.3 "UCR Error Classification")
460 ++ * UC == 1 && PCC == 0 && S == 0
461 ++ */
462 ++ if (!(m.status & MCI_STATUS_PCC) && !(m.status & MCI_STATUS_S))
463 ++ goto log_it;
464 ++
465 ++ /*
466 ++ * Skip anything else. Presumption is that our read of this
467 ++ * bank is racing with a machine check. Leave the log alone
468 ++ * for do_machine_check() to deal with it.
469 ++ */
470 ++ continue;
471 +
472 ++log_it:
473 + error_seen = true;
474 +
475 + mce_read_aux(&m, i);
476 +diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
477 +index 387a8f44fba1..b6b44017cf16 100644
478 +--- a/arch/x86/kernel/cpu/microcode/core.c
479 ++++ b/arch/x86/kernel/cpu/microcode/core.c
480 +@@ -418,8 +418,9 @@ static int do_microcode_update(const void __user *buf, size_t size)
481 + if (ustate == UCODE_ERROR) {
482 + error = -1;
483 + break;
484 +- } else if (ustate == UCODE_OK)
485 ++ } else if (ustate == UCODE_NEW) {
486 + apply_microcode_on_target(cpu);
487 ++ }
488 + }
489 +
490 + return error;
491 +diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
492 +index 0469cd078db1..b50ac9c7397b 100644
493 +--- a/arch/x86/kernel/irq_64.c
494 ++++ b/arch/x86/kernel/irq_64.c
495 +@@ -26,9 +26,18 @@ int sysctl_panic_on_stackoverflow;
496 + /*
497 + * Probabilistic stack overflow check:
498 + *
499 +- * Only check the stack in process context, because everything else
500 +- * runs on the big interrupt stacks. Checking reliably is too expensive,
501 +- * so we just check from interrupts.
502 ++ * Regular device interrupts can enter on the following stacks:
503 ++ *
504 ++ * - User stack
505 ++ *
506 ++ * - Kernel task stack
507 ++ *
508 ++ * - Interrupt stack if a device driver reenables interrupts
509 ++ * which should only happen in really old drivers.
510 ++ *
511 ++ * - Debug IST stack
512 ++ *
513 ++ * All other contexts are invalid.
514 + */
515 + static inline void stack_overflow_check(struct pt_regs *regs)
516 + {
517 +@@ -53,8 +62,8 @@ static inline void stack_overflow_check(struct pt_regs *regs)
518 + return;
519 +
520 + oist = this_cpu_ptr(&orig_ist);
521 +- estack_top = (u64)oist->ist[0] - EXCEPTION_STKSZ + STACK_TOP_MARGIN;
522 +- estack_bottom = (u64)oist->ist[N_EXCEPTION_STACKS - 1];
523 ++ estack_bottom = (u64)oist->ist[DEBUG_STACK];
524 ++ estack_top = estack_bottom - DEBUG_STKSZ + STACK_TOP_MARGIN;
525 + if (regs->sp >= estack_top && regs->sp <= estack_bottom)
526 + return;
527 +
528 +diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
529 +index 4cdc0b27ec82..01741834fd6a 100644
530 +--- a/arch/x86/kernel/signal.c
531 ++++ b/arch/x86/kernel/signal.c
532 +@@ -131,16 +131,6 @@ static int restore_sigcontext(struct pt_regs *regs,
533 + COPY_SEG_CPL3(cs);
534 + COPY_SEG_CPL3(ss);
535 +
536 +-#ifdef CONFIG_X86_64
537 +- /*
538 +- * Fix up SS if needed for the benefit of old DOSEMU and
539 +- * CRIU.
540 +- */
541 +- if (unlikely(!(uc_flags & UC_STRICT_RESTORE_SS) &&
542 +- user_64bit_mode(regs)))
543 +- force_valid_ss(regs);
544 +-#endif
545 +-
546 + get_user_ex(tmpflags, &sc->flags);
547 + regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS);
548 + regs->orig_ax = -1; /* disable syscall checks */
549 +@@ -149,6 +139,15 @@ static int restore_sigcontext(struct pt_regs *regs,
550 + buf = (void __user *)buf_val;
551 + } get_user_catch(err);
552 +
553 ++#ifdef CONFIG_X86_64
554 ++ /*
555 ++ * Fix up SS if needed for the benefit of old DOSEMU and
556 ++ * CRIU.
557 ++ */
558 ++ if (unlikely(!(uc_flags & UC_STRICT_RESTORE_SS) && user_64bit_mode(regs)))
559 ++ force_valid_ss(regs);
560 ++#endif
561 ++
562 + err |= fpu__restore_sig(buf, IS_ENABLED(CONFIG_X86_32));
563 +
564 + force_iret();
565 +@@ -460,6 +459,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
566 + {
567 + struct rt_sigframe __user *frame;
568 + void __user *fp = NULL;
569 ++ unsigned long uc_flags;
570 + int err = 0;
571 +
572 + frame = get_sigframe(&ksig->ka, regs, sizeof(struct rt_sigframe), &fp);
573 +@@ -472,9 +472,11 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
574 + return -EFAULT;
575 + }
576 +
577 ++ uc_flags = frame_uc_flags(regs);
578 ++
579 + put_user_try {
580 + /* Create the ucontext. */
581 +- put_user_ex(frame_uc_flags(regs), &frame->uc.uc_flags);
582 ++ put_user_ex(uc_flags, &frame->uc.uc_flags);
583 + put_user_ex(0, &frame->uc.uc_link);
584 + save_altstack_ex(&frame->uc.uc_stack, regs->sp);
585 +
586 +@@ -540,6 +542,7 @@ static int x32_setup_rt_frame(struct ksignal *ksig,
587 + {
588 + #ifdef CONFIG_X86_X32_ABI
589 + struct rt_sigframe_x32 __user *frame;
590 ++ unsigned long uc_flags;
591 + void __user *restorer;
592 + int err = 0;
593 + void __user *fpstate = NULL;
594 +@@ -554,9 +557,11 @@ static int x32_setup_rt_frame(struct ksignal *ksig,
595 + return -EFAULT;
596 + }
597 +
598 ++ uc_flags = frame_uc_flags(regs);
599 ++
600 + put_user_try {
601 + /* Create the ucontext. */
602 +- put_user_ex(frame_uc_flags(regs), &frame->uc.uc_flags);
603 ++ put_user_ex(uc_flags, &frame->uc.uc_flags);
604 + put_user_ex(0, &frame->uc.uc_link);
605 + compat_save_altstack_ex(&frame->uc.uc_stack, regs->sp);
606 + put_user_ex(0, &frame->uc.uc__pad0);
607 +diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
608 +index 2384a2ae5ec3..23df6eebe82f 100644
609 +--- a/arch/x86/kernel/vmlinux.lds.S
610 ++++ b/arch/x86/kernel/vmlinux.lds.S
611 +@@ -131,11 +131,11 @@ SECTIONS
612 + *(.text.__x86.indirect_thunk)
613 + __indirect_thunk_end = .;
614 + #endif
615 +-
616 +- /* End of text section */
617 +- _etext = .;
618 + } :text = 0x9090
619 +
620 ++ /* End of text section */
621 ++ _etext = .;
622 ++
623 + NOTES :text :note
624 +
625 + EXCEPTION_TABLE(16) :text = 0x9090
626 +diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
627 +index 1296e44fd969..3a7e79f6cc77 100644
628 +--- a/arch/x86/kvm/svm.c
629 ++++ b/arch/x86/kvm/svm.c
630 +@@ -1567,7 +1567,11 @@ static void avic_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
631 + if (!kvm_vcpu_apicv_active(vcpu))
632 + return;
633 +
634 +- if (WARN_ON(h_physical_id >= AVIC_MAX_PHYSICAL_ID_COUNT))
635 ++ /*
636 ++ * Since the host physical APIC id is 8 bits,
637 ++ * we can support host APIC ID upto 255.
638 ++ */
639 ++ if (WARN_ON(h_physical_id > AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK))
640 + return;
641 +
642 + entry = READ_ONCE(*(svm->avic_physical_id_cache));
643 +diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
644 +index 40b1e7ec2399..00d383e3d87a 100644
645 +--- a/arch/x86/kvm/x86.c
646 ++++ b/arch/x86/kvm/x86.c
647 +@@ -1133,7 +1133,7 @@ static int set_efer(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
648 + u64 efer = msr_info->data;
649 +
650 + if (efer & efer_reserved_bits)
651 +- return false;
652 ++ return 1;
653 +
654 + if (!msr_info->host_initiated) {
655 + if (!__kvm_valid_efer(vcpu, efer))
656 +diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
657 +index 794c35c4ca73..b162f92fd55c 100644
658 +--- a/arch/x86/mm/fault.c
659 ++++ b/arch/x86/mm/fault.c
660 +@@ -426,8 +426,6 @@ static noinline int vmalloc_fault(unsigned long address)
661 + if (!(address >= VMALLOC_START && address < VMALLOC_END))
662 + return -1;
663 +
664 +- WARN_ON_ONCE(in_nmi());
665 +-
666 + /*
667 + * Copy kernel mappings over when needed. This can also
668 + * happen within a race in page table update. In the later
669 +diff --git a/block/sed-opal.c b/block/sed-opal.c
670 +index 4f5e70d4abc3..c64011cda9fc 100644
671 +--- a/block/sed-opal.c
672 ++++ b/block/sed-opal.c
673 +@@ -2078,13 +2078,16 @@ static int opal_erase_locking_range(struct opal_dev *dev,
674 + static int opal_enable_disable_shadow_mbr(struct opal_dev *dev,
675 + struct opal_mbr_data *opal_mbr)
676 + {
677 ++ u8 enable_disable = opal_mbr->enable_disable == OPAL_MBR_ENABLE ?
678 ++ OPAL_TRUE : OPAL_FALSE;
679 ++
680 + const struct opal_step mbr_steps[] = {
681 + { opal_discovery0, },
682 + { start_admin1LSP_opal_session, &opal_mbr->key },
683 +- { set_mbr_done, &opal_mbr->enable_disable },
684 ++ { set_mbr_done, &enable_disable },
685 + { end_opal_session, },
686 + { start_admin1LSP_opal_session, &opal_mbr->key },
687 +- { set_mbr_enable_disable, &opal_mbr->enable_disable },
688 ++ { set_mbr_enable_disable, &enable_disable },
689 + { end_opal_session, },
690 + { NULL, }
691 + };
692 +@@ -2204,7 +2207,7 @@ static int __opal_lock_unlock(struct opal_dev *dev,
693 +
694 + static int __opal_set_mbr_done(struct opal_dev *dev, struct opal_key *key)
695 + {
696 +- u8 mbr_done_tf = 1;
697 ++ u8 mbr_done_tf = OPAL_TRUE;
698 + const struct opal_step mbrdone_step [] = {
699 + { opal_discovery0, },
700 + { start_admin1LSP_opal_session, key },
701 +diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
702 +index e26ea209b63e..7a3194e2e090 100644
703 +--- a/drivers/acpi/property.c
704 ++++ b/drivers/acpi/property.c
705 +@@ -943,6 +943,14 @@ struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode,
706 + const struct acpi_data_node *data = to_acpi_data_node(fwnode);
707 + struct acpi_data_node *dn;
708 +
709 ++ /*
710 ++ * We can have a combination of device and data nodes, e.g. with
711 ++ * hierarchical _DSD properties. Make sure the adev pointer is
712 ++ * restored before going through data nodes, otherwise we will
713 ++ * be looking for data_nodes below the last device found instead
714 ++ * of the common fwnode shared by device_nodes and data_nodes.
715 ++ */
716 ++ adev = to_acpi_device_node(fwnode);
717 + if (adev)
718 + head = &adev->data.subnodes;
719 + else if (data)
720 +diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
721 +index d16b40cd26cc..a30ff97632a5 100644
722 +--- a/drivers/base/power/main.c
723 ++++ b/drivers/base/power/main.c
724 +@@ -1485,6 +1485,10 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
725 + if (dev->power.syscore)
726 + goto Complete;
727 +
728 ++ /* Avoid direct_complete to let wakeup_path propagate. */
729 ++ if (device_may_wakeup(dev) || dev->power.wakeup_path)
730 ++ dev->power.direct_complete = false;
731 ++
732 + if (dev->power.direct_complete) {
733 + if (pm_runtime_status_suspended(dev)) {
734 + pm_runtime_disable(dev);
735 +diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c
736 +index 74d11ae6abe9..25173454efa3 100644
737 +--- a/drivers/char/hw_random/omap-rng.c
738 ++++ b/drivers/char/hw_random/omap-rng.c
739 +@@ -442,6 +442,7 @@ static int omap_rng_probe(struct platform_device *pdev)
740 + priv->rng.read = omap_rng_do_read;
741 + priv->rng.init = omap_rng_init;
742 + priv->rng.cleanup = omap_rng_cleanup;
743 ++ priv->rng.quality = 900;
744 +
745 + priv->rng.priv = (unsigned long)priv;
746 + platform_set_drvdata(pdev, priv);
747 +diff --git a/drivers/char/random.c b/drivers/char/random.c
748 +index ea4dbfa30657..e6efa07e9f9e 100644
749 +--- a/drivers/char/random.c
750 ++++ b/drivers/char/random.c
751 +@@ -2188,8 +2188,8 @@ struct batched_entropy {
752 + u32 entropy_u32[CHACHA20_BLOCK_SIZE / sizeof(u32)];
753 + };
754 + unsigned int position;
755 ++ spinlock_t batch_lock;
756 + };
757 +-static rwlock_t batched_entropy_reset_lock = __RW_LOCK_UNLOCKED(batched_entropy_reset_lock);
758 +
759 + /*
760 + * Get a random word for internal kernel use only. The quality of the random
761 +@@ -2199,12 +2199,14 @@ static rwlock_t batched_entropy_reset_lock = __RW_LOCK_UNLOCKED(batched_entropy_
762 + * wait_for_random_bytes() should be called and return 0 at least once
763 + * at any point prior.
764 + */
765 +-static DEFINE_PER_CPU(struct batched_entropy, batched_entropy_u64);
766 ++static DEFINE_PER_CPU(struct batched_entropy, batched_entropy_u64) = {
767 ++ .batch_lock = __SPIN_LOCK_UNLOCKED(batched_entropy_u64.lock),
768 ++};
769 ++
770 + u64 get_random_u64(void)
771 + {
772 + u64 ret;
773 +- bool use_lock;
774 +- unsigned long flags = 0;
775 ++ unsigned long flags;
776 + struct batched_entropy *batch;
777 + static void *previous;
778 +
779 +@@ -2219,28 +2221,25 @@ u64 get_random_u64(void)
780 +
781 + warn_unseeded_randomness(&previous);
782 +
783 +- use_lock = READ_ONCE(crng_init) < 2;
784 +- batch = &get_cpu_var(batched_entropy_u64);
785 +- if (use_lock)
786 +- read_lock_irqsave(&batched_entropy_reset_lock, flags);
787 ++ batch = raw_cpu_ptr(&batched_entropy_u64);
788 ++ spin_lock_irqsave(&batch->batch_lock, flags);
789 + if (batch->position % ARRAY_SIZE(batch->entropy_u64) == 0) {
790 + extract_crng((u8 *)batch->entropy_u64);
791 + batch->position = 0;
792 + }
793 + ret = batch->entropy_u64[batch->position++];
794 +- if (use_lock)
795 +- read_unlock_irqrestore(&batched_entropy_reset_lock, flags);
796 +- put_cpu_var(batched_entropy_u64);
797 ++ spin_unlock_irqrestore(&batch->batch_lock, flags);
798 + return ret;
799 + }
800 + EXPORT_SYMBOL(get_random_u64);
801 +
802 +-static DEFINE_PER_CPU(struct batched_entropy, batched_entropy_u32);
803 ++static DEFINE_PER_CPU(struct batched_entropy, batched_entropy_u32) = {
804 ++ .batch_lock = __SPIN_LOCK_UNLOCKED(batched_entropy_u32.lock),
805 ++};
806 + u32 get_random_u32(void)
807 + {
808 + u32 ret;
809 +- bool use_lock;
810 +- unsigned long flags = 0;
811 ++ unsigned long flags;
812 + struct batched_entropy *batch;
813 + static void *previous;
814 +
815 +@@ -2249,18 +2248,14 @@ u32 get_random_u32(void)
816 +
817 + warn_unseeded_randomness(&previous);
818 +
819 +- use_lock = READ_ONCE(crng_init) < 2;
820 +- batch = &get_cpu_var(batched_entropy_u32);
821 +- if (use_lock)
822 +- read_lock_irqsave(&batched_entropy_reset_lock, flags);
823 ++ batch = raw_cpu_ptr(&batched_entropy_u32);
824 ++ spin_lock_irqsave(&batch->batch_lock, flags);
825 + if (batch->position % ARRAY_SIZE(batch->entropy_u32) == 0) {
826 + extract_crng((u8 *)batch->entropy_u32);
827 + batch->position = 0;
828 + }
829 + ret = batch->entropy_u32[batch->position++];
830 +- if (use_lock)
831 +- read_unlock_irqrestore(&batched_entropy_reset_lock, flags);
832 +- put_cpu_var(batched_entropy_u32);
833 ++ spin_unlock_irqrestore(&batch->batch_lock, flags);
834 + return ret;
835 + }
836 + EXPORT_SYMBOL(get_random_u32);
837 +@@ -2274,12 +2269,19 @@ static void invalidate_batched_entropy(void)
838 + int cpu;
839 + unsigned long flags;
840 +
841 +- write_lock_irqsave(&batched_entropy_reset_lock, flags);
842 + for_each_possible_cpu (cpu) {
843 +- per_cpu_ptr(&batched_entropy_u32, cpu)->position = 0;
844 +- per_cpu_ptr(&batched_entropy_u64, cpu)->position = 0;
845 ++ struct batched_entropy *batched_entropy;
846 ++
847 ++ batched_entropy = per_cpu_ptr(&batched_entropy_u32, cpu);
848 ++ spin_lock_irqsave(&batched_entropy->batch_lock, flags);
849 ++ batched_entropy->position = 0;
850 ++ spin_unlock(&batched_entropy->batch_lock);
851 ++
852 ++ batched_entropy = per_cpu_ptr(&batched_entropy_u64, cpu);
853 ++ spin_lock(&batched_entropy->batch_lock);
854 ++ batched_entropy->position = 0;
855 ++ spin_unlock_irqrestore(&batched_entropy->batch_lock, flags);
856 + }
857 +- write_unlock_irqrestore(&batched_entropy_reset_lock, flags);
858 + }
859 +
860 + /**
861 +diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
862 +index a089474cb046..65454acd4b97 100644
863 +--- a/drivers/char/virtio_console.c
864 ++++ b/drivers/char/virtio_console.c
865 +@@ -75,7 +75,7 @@ struct ports_driver_data {
866 + /* All the console devices handled by this driver */
867 + struct list_head consoles;
868 + };
869 +-static struct ports_driver_data pdrvdata;
870 ++static struct ports_driver_data pdrvdata = { .next_vtermno = 1};
871 +
872 + static DEFINE_SPINLOCK(pdrvdata_lock);
873 + static DECLARE_COMPLETION(early_console_added);
874 +@@ -1422,6 +1422,7 @@ static int add_port(struct ports_device *portdev, u32 id)
875 + port->async_queue = NULL;
876 +
877 + port->cons.ws.ws_row = port->cons.ws.ws_col = 0;
878 ++ port->cons.vtermno = 0;
879 +
880 + port->host_connected = port->guest_connected = false;
881 + port->stats = (struct port_stats) { 0 };
882 +diff --git a/drivers/clk/rockchip/clk-rk3288.c b/drivers/clk/rockchip/clk-rk3288.c
883 +index 450de24a1b42..64191694ff6e 100644
884 +--- a/drivers/clk/rockchip/clk-rk3288.c
885 ++++ b/drivers/clk/rockchip/clk-rk3288.c
886 +@@ -198,7 +198,7 @@ PNAME(mux_hsadcout_p) = { "hsadc_src", "ext_hsadc" };
887 + PNAME(mux_edp_24m_p) = { "ext_edp_24m", "xin24m" };
888 + PNAME(mux_tspout_p) = { "cpll", "gpll", "npll", "xin27m" };
889 +
890 +-PNAME(mux_aclk_vcodec_pre_p) = { "aclk_vepu", "aclk_vdpu" };
891 ++PNAME(mux_aclk_vcodec_pre_p) = { "aclk_vdpu", "aclk_vepu" };
892 + PNAME(mux_usbphy480m_p) = { "sclk_otgphy1_480m", "sclk_otgphy2_480m",
893 + "sclk_otgphy0_480m" };
894 + PNAME(mux_hsicphy480m_p) = { "cpll", "gpll", "usbphy480m_src" };
895 +@@ -292,13 +292,13 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = {
896 + COMPOSITE_NOMUX(0, "aclk_core_mp", "armclk", CLK_IGNORE_UNUSED,
897 + RK3288_CLKSEL_CON(0), 4, 4, DFLAGS | CLK_DIVIDER_READ_ONLY,
898 + RK3288_CLKGATE_CON(12), 6, GFLAGS),
899 +- COMPOSITE_NOMUX(0, "atclk", "armclk", CLK_IGNORE_UNUSED,
900 ++ COMPOSITE_NOMUX(0, "atclk", "armclk", 0,
901 + RK3288_CLKSEL_CON(37), 4, 5, DFLAGS | CLK_DIVIDER_READ_ONLY,
902 + RK3288_CLKGATE_CON(12), 7, GFLAGS),
903 + COMPOSITE_NOMUX(0, "pclk_dbg_pre", "armclk", CLK_IGNORE_UNUSED,
904 + RK3288_CLKSEL_CON(37), 9, 5, DFLAGS | CLK_DIVIDER_READ_ONLY,
905 + RK3288_CLKGATE_CON(12), 8, GFLAGS),
906 +- GATE(0, "pclk_dbg", "pclk_dbg_pre", CLK_IGNORE_UNUSED,
907 ++ GATE(0, "pclk_dbg", "pclk_dbg_pre", 0,
908 + RK3288_CLKGATE_CON(12), 9, GFLAGS),
909 + GATE(0, "cs_dbg", "pclk_dbg_pre", CLK_IGNORE_UNUSED,
910 + RK3288_CLKGATE_CON(12), 10, GFLAGS),
911 +@@ -399,7 +399,7 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = {
912 + COMPOSITE(0, "aclk_vdpu", mux_pll_src_cpll_gpll_usb480m_p, 0,
913 + RK3288_CLKSEL_CON(32), 14, 2, MFLAGS, 8, 5, DFLAGS,
914 + RK3288_CLKGATE_CON(3), 11, GFLAGS),
915 +- MUXGRF(0, "aclk_vcodec_pre", mux_aclk_vcodec_pre_p, 0,
916 ++ MUXGRF(0, "aclk_vcodec_pre", mux_aclk_vcodec_pre_p, CLK_SET_RATE_PARENT,
917 + RK3288_GRF_SOC_CON(0), 7, 1, MFLAGS),
918 + GATE(ACLK_VCODEC, "aclk_vcodec", "aclk_vcodec_pre", 0,
919 + RK3288_CLKGATE_CON(9), 0, GFLAGS),
920 +@@ -626,7 +626,7 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = {
921 + INVERTER(SCLK_HSADC, "sclk_hsadc", "sclk_hsadc_out",
922 + RK3288_CLKSEL_CON(22), 7, IFLAGS),
923 +
924 +- GATE(0, "jtag", "ext_jtag", CLK_IGNORE_UNUSED,
925 ++ GATE(0, "jtag", "ext_jtag", 0,
926 + RK3288_CLKGATE_CON(4), 14, GFLAGS),
927 +
928 + COMPOSITE_NODIV(SCLK_USBPHY480M_SRC, "usbphy480m_src", mux_usbphy480m_p, 0,
929 +@@ -635,7 +635,7 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = {
930 + COMPOSITE_NODIV(SCLK_HSICPHY480M, "sclk_hsicphy480m", mux_hsicphy480m_p, 0,
931 + RK3288_CLKSEL_CON(29), 0, 2, MFLAGS,
932 + RK3288_CLKGATE_CON(3), 6, GFLAGS),
933 +- GATE(0, "hsicphy12m_xin12m", "xin12m", CLK_IGNORE_UNUSED,
934 ++ GATE(0, "hsicphy12m_xin12m", "xin12m", 0,
935 + RK3288_CLKGATE_CON(13), 9, GFLAGS),
936 + DIV(0, "hsicphy12m_usbphy", "sclk_hsicphy480m", 0,
937 + RK3288_CLKSEL_CON(11), 8, 6, DFLAGS),
938 +@@ -676,7 +676,7 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = {
939 + GATE(PCLK_TZPC, "pclk_tzpc", "pclk_cpu", 0, RK3288_CLKGATE_CON(11), 3, GFLAGS),
940 + GATE(PCLK_UART2, "pclk_uart2", "pclk_cpu", 0, RK3288_CLKGATE_CON(11), 9, GFLAGS),
941 + GATE(PCLK_EFUSE256, "pclk_efuse_256", "pclk_cpu", 0, RK3288_CLKGATE_CON(11), 10, GFLAGS),
942 +- GATE(PCLK_RKPWM, "pclk_rkpwm", "pclk_cpu", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(11), 11, GFLAGS),
943 ++ GATE(PCLK_RKPWM, "pclk_rkpwm", "pclk_cpu", 0, RK3288_CLKGATE_CON(11), 11, GFLAGS),
944 +
945 + /* ddrctrl [DDR Controller PHY clock] gates */
946 + GATE(0, "nclk_ddrupctl0", "ddrphy", CLK_IGNORE_UNUSED, RK3288_CLKGATE_CON(11), 4, GFLAGS),
947 +@@ -816,12 +816,9 @@ static const char *const rk3288_critical_clocks[] __initconst = {
948 + "pclk_alive_niu",
949 + "pclk_pd_pmu",
950 + "pclk_pmu_niu",
951 +- "pclk_core_niu",
952 +- "pclk_ddrupctl0",
953 +- "pclk_publ0",
954 +- "pclk_ddrupctl1",
955 +- "pclk_publ1",
956 + "pmu_hclk_otg0",
957 ++ /* pwm-regulators on some boards, so handoff-critical later */
958 ++ "pclk_rkpwm",
959 + };
960 +
961 + static void __iomem *rk3288_cru_base;
962 +diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
963 +index 9f5c51cd67ad..fceb18d26db8 100644
964 +--- a/drivers/cpufreq/cpufreq.c
965 ++++ b/drivers/cpufreq/cpufreq.c
966 +@@ -1101,6 +1101,7 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
967 + cpufreq_global_kobject, "policy%u", cpu);
968 + if (ret) {
969 + pr_err("%s: failed to init policy->kobj: %d\n", __func__, ret);
970 ++ kobject_put(&policy->kobj);
971 + goto err_free_real_cpus;
972 + }
973 +
974 +diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
975 +index 6a16d22bc604..146237aab395 100644
976 +--- a/drivers/cpufreq/cpufreq_governor.c
977 ++++ b/drivers/cpufreq/cpufreq_governor.c
978 +@@ -459,6 +459,8 @@ int cpufreq_dbs_governor_init(struct cpufreq_policy *policy)
979 + /* Failure, so roll back. */
980 + pr_err("initialization failed (dbs_data kobject init error %d)\n", ret);
981 +
982 ++ kobject_put(&dbs_data->attr_set.kobj);
983 ++
984 + policy->governor_data = NULL;
985 +
986 + if (!have_governor_per_policy())
987 +diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
988 +index c2dd43f3f5d8..8d63a6dc8383 100644
989 +--- a/drivers/cpufreq/kirkwood-cpufreq.c
990 ++++ b/drivers/cpufreq/kirkwood-cpufreq.c
991 +@@ -124,13 +124,14 @@ static int kirkwood_cpufreq_probe(struct platform_device *pdev)
992 + priv.cpu_clk = of_clk_get_by_name(np, "cpu_clk");
993 + if (IS_ERR(priv.cpu_clk)) {
994 + dev_err(priv.dev, "Unable to get cpuclk\n");
995 +- return PTR_ERR(priv.cpu_clk);
996 ++ err = PTR_ERR(priv.cpu_clk);
997 ++ goto out_node;
998 + }
999 +
1000 + err = clk_prepare_enable(priv.cpu_clk);
1001 + if (err) {
1002 + dev_err(priv.dev, "Unable to prepare cpuclk\n");
1003 +- return err;
1004 ++ goto out_node;
1005 + }
1006 +
1007 + kirkwood_freq_table[0].frequency = clk_get_rate(priv.cpu_clk) / 1000;
1008 +@@ -161,20 +162,22 @@ static int kirkwood_cpufreq_probe(struct platform_device *pdev)
1009 + goto out_ddr;
1010 + }
1011 +
1012 +- of_node_put(np);
1013 +- np = NULL;
1014 +-
1015 + err = cpufreq_register_driver(&kirkwood_cpufreq_driver);
1016 +- if (!err)
1017 +- return 0;
1018 ++ if (err) {
1019 ++ dev_err(priv.dev, "Failed to register cpufreq driver\n");
1020 ++ goto out_powersave;
1021 ++ }
1022 +
1023 +- dev_err(priv.dev, "Failed to register cpufreq driver\n");
1024 ++ of_node_put(np);
1025 ++ return 0;
1026 +
1027 ++out_powersave:
1028 + clk_disable_unprepare(priv.powersave_clk);
1029 + out_ddr:
1030 + clk_disable_unprepare(priv.ddr_clk);
1031 + out_cpu:
1032 + clk_disable_unprepare(priv.cpu_clk);
1033 ++out_node:
1034 + of_node_put(np);
1035 +
1036 + return err;
1037 +diff --git a/drivers/cpufreq/pasemi-cpufreq.c b/drivers/cpufreq/pasemi-cpufreq.c
1038 +index b257fc7d5204..8456492124f0 100644
1039 +--- a/drivers/cpufreq/pasemi-cpufreq.c
1040 ++++ b/drivers/cpufreq/pasemi-cpufreq.c
1041 +@@ -146,6 +146,7 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)
1042 +
1043 + cpu = of_get_cpu_node(policy->cpu, NULL);
1044 +
1045 ++ of_node_put(cpu);
1046 + if (!cpu)
1047 + goto out;
1048 +
1049 +diff --git a/drivers/cpufreq/pmac32-cpufreq.c b/drivers/cpufreq/pmac32-cpufreq.c
1050 +index 61ae06ca008e..e225edb5c359 100644
1051 +--- a/drivers/cpufreq/pmac32-cpufreq.c
1052 ++++ b/drivers/cpufreq/pmac32-cpufreq.c
1053 +@@ -552,6 +552,7 @@ static int pmac_cpufreq_init_7447A(struct device_node *cpunode)
1054 + volt_gpio_np = of_find_node_by_name(NULL, "cpu-vcore-select");
1055 + if (volt_gpio_np)
1056 + voltage_gpio = read_gpio(volt_gpio_np);
1057 ++ of_node_put(volt_gpio_np);
1058 + if (!voltage_gpio){
1059 + pr_err("missing cpu-vcore-select gpio\n");
1060 + return 1;
1061 +@@ -588,6 +589,7 @@ static int pmac_cpufreq_init_750FX(struct device_node *cpunode)
1062 + if (volt_gpio_np)
1063 + voltage_gpio = read_gpio(volt_gpio_np);
1064 +
1065 ++ of_node_put(volt_gpio_np);
1066 + pvr = mfspr(SPRN_PVR);
1067 + has_cpu_l2lve = !((pvr & 0xf00) == 0x100);
1068 +
1069 +diff --git a/drivers/cpufreq/ppc_cbe_cpufreq.c b/drivers/cpufreq/ppc_cbe_cpufreq.c
1070 +index 5a4c5a639f61..2eaeebcc93af 100644
1071 +--- a/drivers/cpufreq/ppc_cbe_cpufreq.c
1072 ++++ b/drivers/cpufreq/ppc_cbe_cpufreq.c
1073 +@@ -86,6 +86,7 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy)
1074 + if (!cbe_get_cpu_pmd_regs(policy->cpu) ||
1075 + !cbe_get_cpu_mic_tm_regs(policy->cpu)) {
1076 + pr_info("invalid CBE regs pointers for cpufreq\n");
1077 ++ of_node_put(cpu);
1078 + return -EINVAL;
1079 + }
1080 +
1081 +diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
1082 +index a4b5ff2b72f8..f6936bb3b7be 100644
1083 +--- a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
1084 ++++ b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
1085 +@@ -240,7 +240,10 @@ static int sun4i_hash(struct ahash_request *areq)
1086 + }
1087 + } else {
1088 + /* Since we have the flag final, we can go up to modulo 4 */
1089 +- end = ((areq->nbytes + op->len) / 4) * 4 - op->len;
1090 ++ if (areq->nbytes < 4)
1091 ++ end = 0;
1092 ++ else
1093 ++ end = ((areq->nbytes + op->len) / 4) * 4 - op->len;
1094 + }
1095 +
1096 + /* TODO if SGlen % 4 and !op->len then DMA */
1097 +diff --git a/drivers/crypto/vmx/aesp8-ppc.pl b/drivers/crypto/vmx/aesp8-ppc.pl
1098 +index d9281a28818d..930a3f1e3ec0 100644
1099 +--- a/drivers/crypto/vmx/aesp8-ppc.pl
1100 ++++ b/drivers/crypto/vmx/aesp8-ppc.pl
1101 +@@ -1318,7 +1318,7 @@ Loop_ctr32_enc:
1102 + addi $idx,$idx,16
1103 + bdnz Loop_ctr32_enc
1104 +
1105 +- vadduwm $ivec,$ivec,$one
1106 ++ vadduqm $ivec,$ivec,$one
1107 + vmr $dat,$inptail
1108 + lvx $inptail,0,$inp
1109 + addi $inp,$inp,16
1110 +diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
1111 +index 4db2cd1c611d..22764cd30cc3 100644
1112 +--- a/drivers/dma/at_xdmac.c
1113 ++++ b/drivers/dma/at_xdmac.c
1114 +@@ -1606,7 +1606,11 @@ static void at_xdmac_tasklet(unsigned long data)
1115 + struct at_xdmac_desc,
1116 + xfer_node);
1117 + dev_vdbg(chan2dev(&atchan->chan), "%s: desc 0x%p\n", __func__, desc);
1118 +- BUG_ON(!desc->active_xfer);
1119 ++ if (!desc->active_xfer) {
1120 ++ dev_err(chan2dev(&atchan->chan), "Xfer not active: exiting");
1121 ++ spin_unlock_bh(&atchan->lock);
1122 ++ return;
1123 ++ }
1124 +
1125 + txd = &desc->tx_dma_desc;
1126 +
1127 +diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
1128 +index 6afd42cfbf5d..b4fa555a243f 100644
1129 +--- a/drivers/dma/pl330.c
1130 ++++ b/drivers/dma/pl330.c
1131 +@@ -960,6 +960,7 @@ static void _stop(struct pl330_thread *thrd)
1132 + {
1133 + void __iomem *regs = thrd->dmac->base;
1134 + u8 insn[6] = {0, 0, 0, 0, 0, 0};
1135 ++ u32 inten = readl(regs + INTEN);
1136 +
1137 + if (_state(thrd) == PL330_STATE_FAULT_COMPLETING)
1138 + UNTIL(thrd, PL330_STATE_FAULTING | PL330_STATE_KILLING);
1139 +@@ -972,10 +973,13 @@ static void _stop(struct pl330_thread *thrd)
1140 +
1141 + _emit_KILL(0, insn);
1142 +
1143 +- /* Stop generating interrupts for SEV */
1144 +- writel(readl(regs + INTEN) & ~(1 << thrd->ev), regs + INTEN);
1145 +-
1146 + _execute_DBGINSN(thrd, insn, is_manager(thrd));
1147 ++
1148 ++ /* clear the event */
1149 ++ if (inten & (1 << thrd->ev))
1150 ++ writel(1 << thrd->ev, regs + INTCLR);
1151 ++ /* Stop generating interrupts for SEV */
1152 ++ writel(inten & ~(1 << thrd->ev), regs + INTEN);
1153 + }
1154 +
1155 + /* Start doing req 'idx' of thread 'thrd' */
1156 +diff --git a/drivers/dma/tegra210-adma.c b/drivers/dma/tegra210-adma.c
1157 +index b26256f23d67..09b6756366c3 100644
1158 +--- a/drivers/dma/tegra210-adma.c
1159 ++++ b/drivers/dma/tegra210-adma.c
1160 +@@ -22,7 +22,6 @@
1161 + #include <linux/of_device.h>
1162 + #include <linux/of_dma.h>
1163 + #include <linux/of_irq.h>
1164 +-#include <linux/pm_clock.h>
1165 + #include <linux/pm_runtime.h>
1166 + #include <linux/slab.h>
1167 +
1168 +@@ -141,6 +140,7 @@ struct tegra_adma {
1169 + struct dma_device dma_dev;
1170 + struct device *dev;
1171 + void __iomem *base_addr;
1172 ++ struct clk *ahub_clk;
1173 + unsigned int nr_channels;
1174 + unsigned long rx_requests_reserved;
1175 + unsigned long tx_requests_reserved;
1176 +@@ -637,8 +637,9 @@ static int tegra_adma_runtime_suspend(struct device *dev)
1177 + struct tegra_adma *tdma = dev_get_drvdata(dev);
1178 +
1179 + tdma->global_cmd = tdma_read(tdma, ADMA_GLOBAL_CMD);
1180 ++ clk_disable_unprepare(tdma->ahub_clk);
1181 +
1182 +- return pm_clk_suspend(dev);
1183 ++ return 0;
1184 + }
1185 +
1186 + static int tegra_adma_runtime_resume(struct device *dev)
1187 +@@ -646,10 +647,11 @@ static int tegra_adma_runtime_resume(struct device *dev)
1188 + struct tegra_adma *tdma = dev_get_drvdata(dev);
1189 + int ret;
1190 +
1191 +- ret = pm_clk_resume(dev);
1192 +- if (ret)
1193 ++ ret = clk_prepare_enable(tdma->ahub_clk);
1194 ++ if (ret) {
1195 ++ dev_err(dev, "ahub clk_enable failed: %d\n", ret);
1196 + return ret;
1197 +-
1198 ++ }
1199 + tdma_write(tdma, ADMA_GLOBAL_CMD, tdma->global_cmd);
1200 +
1201 + return 0;
1202 +@@ -692,13 +694,11 @@ static int tegra_adma_probe(struct platform_device *pdev)
1203 + if (IS_ERR(tdma->base_addr))
1204 + return PTR_ERR(tdma->base_addr);
1205 +
1206 +- ret = pm_clk_create(&pdev->dev);
1207 +- if (ret)
1208 +- return ret;
1209 +-
1210 +- ret = of_pm_clk_add_clk(&pdev->dev, "d_audio");
1211 +- if (ret)
1212 +- goto clk_destroy;
1213 ++ tdma->ahub_clk = devm_clk_get(&pdev->dev, "d_audio");
1214 ++ if (IS_ERR(tdma->ahub_clk)) {
1215 ++ dev_err(&pdev->dev, "Error: Missing ahub controller clock\n");
1216 ++ return PTR_ERR(tdma->ahub_clk);
1217 ++ }
1218 +
1219 + pm_runtime_enable(&pdev->dev);
1220 +
1221 +@@ -775,8 +775,6 @@ rpm_put:
1222 + pm_runtime_put_sync(&pdev->dev);
1223 + rpm_disable:
1224 + pm_runtime_disable(&pdev->dev);
1225 +-clk_destroy:
1226 +- pm_clk_destroy(&pdev->dev);
1227 +
1228 + return ret;
1229 + }
1230 +@@ -786,6 +784,7 @@ static int tegra_adma_remove(struct platform_device *pdev)
1231 + struct tegra_adma *tdma = platform_get_drvdata(pdev);
1232 + int i;
1233 +
1234 ++ of_dma_controller_free(pdev->dev.of_node);
1235 + dma_async_device_unregister(&tdma->dma_dev);
1236 +
1237 + for (i = 0; i < tdma->nr_channels; ++i)
1238 +@@ -793,7 +792,6 @@ static int tegra_adma_remove(struct platform_device *pdev)
1239 +
1240 + pm_runtime_put_sync(&pdev->dev);
1241 + pm_runtime_disable(&pdev->dev);
1242 +- pm_clk_destroy(&pdev->dev);
1243 +
1244 + return 0;
1245 + }
1246 +diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
1247 +index f84da4a17724..4937a404fee8 100644
1248 +--- a/drivers/extcon/extcon-arizona.c
1249 ++++ b/drivers/extcon/extcon-arizona.c
1250 +@@ -1726,6 +1726,16 @@ static int arizona_extcon_remove(struct platform_device *pdev)
1251 + struct arizona_extcon_info *info = platform_get_drvdata(pdev);
1252 + struct arizona *arizona = info->arizona;
1253 + int jack_irq_rise, jack_irq_fall;
1254 ++ bool change;
1255 ++
1256 ++ regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1,
1257 ++ ARIZONA_MICD_ENA, 0,
1258 ++ &change);
1259 ++
1260 ++ if (change) {
1261 ++ regulator_disable(info->micvdd);
1262 ++ pm_runtime_put(info->dev);
1263 ++ }
1264 +
1265 + gpiod_put(info->micd_pol_gpio);
1266 +
1267 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
1268 +index 333bad749067..415e9a384799 100644
1269 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
1270 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
1271 +@@ -135,8 +135,9 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **f)
1272 + {
1273 + struct amdgpu_device *adev = ring->adev;
1274 + struct amdgpu_fence *fence;
1275 +- struct dma_fence *old, **ptr;
1276 ++ struct dma_fence __rcu **ptr;
1277 + uint32_t seq;
1278 ++ int r;
1279 +
1280 + fence = kmem_cache_alloc(amdgpu_fence_slab, GFP_KERNEL);
1281 + if (fence == NULL)
1282 +@@ -152,15 +153,24 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **f)
1283 + seq, AMDGPU_FENCE_FLAG_INT);
1284 +
1285 + ptr = &ring->fence_drv.fences[seq & ring->fence_drv.num_fences_mask];
1286 ++ if (unlikely(rcu_dereference_protected(*ptr, 1))) {
1287 ++ struct dma_fence *old;
1288 ++
1289 ++ rcu_read_lock();
1290 ++ old = dma_fence_get_rcu_safe(ptr);
1291 ++ rcu_read_unlock();
1292 ++
1293 ++ if (old) {
1294 ++ r = dma_fence_wait(old, false);
1295 ++ dma_fence_put(old);
1296 ++ if (r)
1297 ++ return r;
1298 ++ }
1299 ++ }
1300 ++
1301 + /* This function can't be called concurrently anyway, otherwise
1302 + * emitting the fence would mess up the hardware ring buffer.
1303 + */
1304 +- old = rcu_dereference_protected(*ptr, 1);
1305 +- if (old && !dma_fence_is_signaled(old)) {
1306 +- DRM_INFO("rcu slot is busy\n");
1307 +- dma_fence_wait(old, false);
1308 +- }
1309 +-
1310 + rcu_assign_pointer(*ptr, dma_fence_get(&fence->base));
1311 +
1312 + *f = &fence->base;
1313 +diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
1314 +index a7b6734bc3c3..340440febf9a 100644
1315 +--- a/drivers/gpu/drm/drm_drv.c
1316 ++++ b/drivers/gpu/drm/drm_drv.c
1317 +@@ -505,7 +505,7 @@ int drm_dev_init(struct drm_device *dev,
1318 + }
1319 +
1320 + kref_init(&dev->ref);
1321 +- dev->dev = parent;
1322 ++ dev->dev = get_device(parent);
1323 + dev->driver = driver;
1324 +
1325 + INIT_LIST_HEAD(&dev->filelist);
1326 +@@ -572,6 +572,7 @@ err_minors:
1327 + drm_minor_free(dev, DRM_MINOR_CONTROL);
1328 + drm_fs_inode_free(dev->anon_inode);
1329 + err_free:
1330 ++ put_device(dev->dev);
1331 + mutex_destroy(&dev->master_mutex);
1332 + mutex_destroy(&dev->ctxlist_mutex);
1333 + mutex_destroy(&dev->filelist_mutex);
1334 +@@ -607,6 +608,8 @@ void drm_dev_fini(struct drm_device *dev)
1335 + drm_minor_free(dev, DRM_MINOR_RENDER);
1336 + drm_minor_free(dev, DRM_MINOR_CONTROL);
1337 +
1338 ++ put_device(dev->dev);
1339 ++
1340 + mutex_destroy(&dev->master_mutex);
1341 + mutex_destroy(&dev->ctxlist_mutex);
1342 + mutex_destroy(&dev->filelist_mutex);
1343 +diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
1344 +index 03244b3c985d..3cf07f5063ff 100644
1345 +--- a/drivers/gpu/drm/drm_file.c
1346 ++++ b/drivers/gpu/drm/drm_file.c
1347 +@@ -525,6 +525,7 @@ put_back_event:
1348 + file_priv->event_space -= length;
1349 + list_add(&e->link, &file_priv->event_list);
1350 + spin_unlock_irq(&dev->event_lock);
1351 ++ wake_up_interruptible(&file_priv->event_wait);
1352 + break;
1353 + }
1354 +
1355 +diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
1356 +index 17c59d839e6f..f1aaa76cc2e4 100644
1357 +--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
1358 ++++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
1359 +@@ -29,7 +29,7 @@ static void a5xx_dump(struct msm_gpu *gpu);
1360 + static int zap_shader_load_mdt(struct device *dev, const char *fwname)
1361 + {
1362 + const struct firmware *fw;
1363 +- struct device_node *np;
1364 ++ struct device_node *np, *mem_np;
1365 + struct resource r;
1366 + phys_addr_t mem_phys;
1367 + ssize_t mem_size;
1368 +@@ -43,11 +43,13 @@ static int zap_shader_load_mdt(struct device *dev, const char *fwname)
1369 + if (!np)
1370 + return -ENODEV;
1371 +
1372 +- np = of_parse_phandle(np, "memory-region", 0);
1373 +- if (!np)
1374 ++ mem_np = of_parse_phandle(np, "memory-region", 0);
1375 ++ of_node_put(np);
1376 ++ if (!mem_np)
1377 + return -EINVAL;
1378 +
1379 +- ret = of_address_to_resource(np, 0, &r);
1380 ++ ret = of_address_to_resource(mem_np, 0, &r);
1381 ++ of_node_put(mem_np);
1382 + if (ret)
1383 + return ret;
1384 +
1385 +diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
1386 +index a306493e2e97..7c8049a5bd99 100644
1387 +--- a/drivers/hid/hid-core.c
1388 ++++ b/drivers/hid/hid-core.c
1389 +@@ -199,13 +199,14 @@ static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type)
1390 + * Add a usage to the temporary parser table.
1391 + */
1392 +
1393 +-static int hid_add_usage(struct hid_parser *parser, unsigned usage)
1394 ++static int hid_add_usage(struct hid_parser *parser, unsigned usage, u8 size)
1395 + {
1396 + if (parser->local.usage_index >= HID_MAX_USAGES) {
1397 + hid_err(parser->device, "usage index exceeded\n");
1398 + return -1;
1399 + }
1400 + parser->local.usage[parser->local.usage_index] = usage;
1401 ++ parser->local.usage_size[parser->local.usage_index] = size;
1402 + parser->local.collection_index[parser->local.usage_index] =
1403 + parser->collection_stack_ptr ?
1404 + parser->collection_stack[parser->collection_stack_ptr - 1] : 0;
1405 +@@ -462,10 +463,7 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
1406 + return 0;
1407 + }
1408 +
1409 +- if (item->size <= 2)
1410 +- data = (parser->global.usage_page << 16) + data;
1411 +-
1412 +- return hid_add_usage(parser, data);
1413 ++ return hid_add_usage(parser, data, item->size);
1414 +
1415 + case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM:
1416 +
1417 +@@ -474,9 +472,6 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
1418 + return 0;
1419 + }
1420 +
1421 +- if (item->size <= 2)
1422 +- data = (parser->global.usage_page << 16) + data;
1423 +-
1424 + parser->local.usage_minimum = data;
1425 + return 0;
1426 +
1427 +@@ -487,9 +482,6 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
1428 + return 0;
1429 + }
1430 +
1431 +- if (item->size <= 2)
1432 +- data = (parser->global.usage_page << 16) + data;
1433 +-
1434 + count = data - parser->local.usage_minimum;
1435 + if (count + parser->local.usage_index >= HID_MAX_USAGES) {
1436 + /*
1437 +@@ -509,7 +501,7 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
1438 + }
1439 +
1440 + for (n = parser->local.usage_minimum; n <= data; n++)
1441 +- if (hid_add_usage(parser, n)) {
1442 ++ if (hid_add_usage(parser, n, item->size)) {
1443 + dbg_hid("hid_add_usage failed\n");
1444 + return -1;
1445 + }
1446 +@@ -523,6 +515,22 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
1447 + return 0;
1448 + }
1449 +
1450 ++/*
1451 ++ * Concatenate Usage Pages into Usages where relevant:
1452 ++ * As per specification, 6.2.2.8: "When the parser encounters a main item it
1453 ++ * concatenates the last declared Usage Page with a Usage to form a complete
1454 ++ * usage value."
1455 ++ */
1456 ++
1457 ++static void hid_concatenate_usage_page(struct hid_parser *parser)
1458 ++{
1459 ++ int i;
1460 ++
1461 ++ for (i = 0; i < parser->local.usage_index; i++)
1462 ++ if (parser->local.usage_size[i] <= 2)
1463 ++ parser->local.usage[i] += parser->global.usage_page << 16;
1464 ++}
1465 ++
1466 + /*
1467 + * Process a main item.
1468 + */
1469 +@@ -532,6 +540,8 @@ static int hid_parser_main(struct hid_parser *parser, struct hid_item *item)
1470 + __u32 data;
1471 + int ret;
1472 +
1473 ++ hid_concatenate_usage_page(parser);
1474 ++
1475 + data = item_udata(item);
1476 +
1477 + switch (item->tag) {
1478 +@@ -741,6 +751,8 @@ static int hid_scan_main(struct hid_parser *parser, struct hid_item *item)
1479 + __u32 data;
1480 + int i;
1481 +
1482 ++ hid_concatenate_usage_page(parser);
1483 ++
1484 + data = item_udata(item);
1485 +
1486 + switch (item->tag) {
1487 +diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
1488 +index b83d4173fc7f..b705cbb58ca6 100644
1489 +--- a/drivers/hid/hid-logitech-hidpp.c
1490 ++++ b/drivers/hid/hid-logitech-hidpp.c
1491 +@@ -725,13 +725,16 @@ static int hidpp_root_get_feature(struct hidpp_device *hidpp, u16 feature,
1492 +
1493 + static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp)
1494 + {
1495 ++ const u8 ping_byte = 0x5a;
1496 ++ u8 ping_data[3] = { 0, 0, ping_byte };
1497 + struct hidpp_report response;
1498 + int ret;
1499 +
1500 +- ret = hidpp_send_fap_command_sync(hidpp,
1501 ++ ret = hidpp_send_rap_command_sync(hidpp,
1502 ++ REPORT_ID_HIDPP_SHORT,
1503 + HIDPP_PAGE_ROOT_IDX,
1504 + CMD_ROOT_GET_PROTOCOL_VERSION,
1505 +- NULL, 0, &response);
1506 ++ ping_data, sizeof(ping_data), &response);
1507 +
1508 + if (ret == HIDPP_ERROR_INVALID_SUBID) {
1509 + hidpp->protocol_major = 1;
1510 +@@ -751,8 +754,14 @@ static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp)
1511 + if (ret)
1512 + return ret;
1513 +
1514 +- hidpp->protocol_major = response.fap.params[0];
1515 +- hidpp->protocol_minor = response.fap.params[1];
1516 ++ if (response.rap.params[2] != ping_byte) {
1517 ++ hid_err(hidpp->hid_dev, "%s: ping mismatch 0x%02x != 0x%02x\n",
1518 ++ __func__, response.rap.params[2], ping_byte);
1519 ++ return -EPROTO;
1520 ++ }
1521 ++
1522 ++ hidpp->protocol_major = response.rap.params[0];
1523 ++ hidpp->protocol_minor = response.rap.params[1];
1524 +
1525 + return ret;
1526 + }
1527 +@@ -901,7 +910,11 @@ static int hidpp_map_battery_level(int capacity)
1528 + {
1529 + if (capacity < 11)
1530 + return POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL;
1531 +- else if (capacity < 31)
1532 ++ /*
1533 ++ * The spec says this should be < 31 but some devices report 30
1534 ++ * with brand new batteries and Windows reports 30 as "Good".
1535 ++ */
1536 ++ else if (capacity < 30)
1537 + return POWER_SUPPLY_CAPACITY_LEVEL_LOW;
1538 + else if (capacity < 81)
1539 + return POWER_SUPPLY_CAPACITY_LEVEL_NORMAL;
1540 +diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c
1541 +index 73c681162653..623736d2a7c1 100644
1542 +--- a/drivers/hwmon/f71805f.c
1543 ++++ b/drivers/hwmon/f71805f.c
1544 +@@ -96,17 +96,23 @@ superio_select(int base, int ld)
1545 + outb(ld, base + 1);
1546 + }
1547 +
1548 +-static inline void
1549 ++static inline int
1550 + superio_enter(int base)
1551 + {
1552 ++ if (!request_muxed_region(base, 2, DRVNAME))
1553 ++ return -EBUSY;
1554 ++
1555 + outb(0x87, base);
1556 + outb(0x87, base);
1557 ++
1558 ++ return 0;
1559 + }
1560 +
1561 + static inline void
1562 + superio_exit(int base)
1563 + {
1564 + outb(0xaa, base);
1565 ++ release_region(base, 2);
1566 + }
1567 +
1568 + /*
1569 +@@ -1561,7 +1567,7 @@ exit:
1570 + static int __init f71805f_find(int sioaddr, unsigned short *address,
1571 + struct f71805f_sio_data *sio_data)
1572 + {
1573 +- int err = -ENODEV;
1574 ++ int err;
1575 + u16 devid;
1576 +
1577 + static const char * const names[] = {
1578 +@@ -1569,8 +1575,11 @@ static int __init f71805f_find(int sioaddr, unsigned short *address,
1579 + "F71872F/FG or F71806F/FG",
1580 + };
1581 +
1582 +- superio_enter(sioaddr);
1583 ++ err = superio_enter(sioaddr);
1584 ++ if (err)
1585 ++ return err;
1586 +
1587 ++ err = -ENODEV;
1588 + devid = superio_inw(sioaddr, SIO_REG_MANID);
1589 + if (devid != SIO_FINTEK_ID)
1590 + goto exit;
1591 +diff --git a/drivers/hwmon/pc87427.c b/drivers/hwmon/pc87427.c
1592 +index dc5a9d5ada51..81a05cd1a512 100644
1593 +--- a/drivers/hwmon/pc87427.c
1594 ++++ b/drivers/hwmon/pc87427.c
1595 +@@ -106,6 +106,13 @@ static const char *logdev_str[2] = { DRVNAME " FMC", DRVNAME " HMC" };
1596 + #define LD_IN 1
1597 + #define LD_TEMP 1
1598 +
1599 ++static inline int superio_enter(int sioaddr)
1600 ++{
1601 ++ if (!request_muxed_region(sioaddr, 2, DRVNAME))
1602 ++ return -EBUSY;
1603 ++ return 0;
1604 ++}
1605 ++
1606 + static inline void superio_outb(int sioaddr, int reg, int val)
1607 + {
1608 + outb(reg, sioaddr);
1609 +@@ -122,6 +129,7 @@ static inline void superio_exit(int sioaddr)
1610 + {
1611 + outb(0x02, sioaddr);
1612 + outb(0x02, sioaddr + 1);
1613 ++ release_region(sioaddr, 2);
1614 + }
1615 +
1616 + /*
1617 +@@ -1220,7 +1228,11 @@ static int __init pc87427_find(int sioaddr, struct pc87427_sio_data *sio_data)
1618 + {
1619 + u16 val;
1620 + u8 cfg, cfg_b;
1621 +- int i, err = 0;
1622 ++ int i, err;
1623 ++
1624 ++ err = superio_enter(sioaddr);
1625 ++ if (err)
1626 ++ return err;
1627 +
1628 + /* Identify device */
1629 + val = force_id ? force_id : superio_inb(sioaddr, SIOREG_DEVID);
1630 +diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
1631 +index 6bd200756560..cbdb5c4991ae 100644
1632 +--- a/drivers/hwmon/smsc47b397.c
1633 ++++ b/drivers/hwmon/smsc47b397.c
1634 +@@ -72,14 +72,19 @@ static inline void superio_select(int ld)
1635 + superio_outb(0x07, ld);
1636 + }
1637 +
1638 +-static inline void superio_enter(void)
1639 ++static inline int superio_enter(void)
1640 + {
1641 ++ if (!request_muxed_region(REG, 2, DRVNAME))
1642 ++ return -EBUSY;
1643 ++
1644 + outb(0x55, REG);
1645 ++ return 0;
1646 + }
1647 +
1648 + static inline void superio_exit(void)
1649 + {
1650 + outb(0xAA, REG);
1651 ++ release_region(REG, 2);
1652 + }
1653 +
1654 + #define SUPERIO_REG_DEVID 0x20
1655 +@@ -300,8 +305,12 @@ static int __init smsc47b397_find(void)
1656 + u8 id, rev;
1657 + char *name;
1658 + unsigned short addr;
1659 ++ int err;
1660 ++
1661 ++ err = superio_enter();
1662 ++ if (err)
1663 ++ return err;
1664 +
1665 +- superio_enter();
1666 + id = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID);
1667 +
1668 + switch (id) {
1669 +diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
1670 +index c7b6a425e2c0..5eeac9853d0a 100644
1671 +--- a/drivers/hwmon/smsc47m1.c
1672 ++++ b/drivers/hwmon/smsc47m1.c
1673 +@@ -73,16 +73,21 @@ superio_inb(int reg)
1674 + /* logical device for fans is 0x0A */
1675 + #define superio_select() superio_outb(0x07, 0x0A)
1676 +
1677 +-static inline void
1678 ++static inline int
1679 + superio_enter(void)
1680 + {
1681 ++ if (!request_muxed_region(REG, 2, DRVNAME))
1682 ++ return -EBUSY;
1683 ++
1684 + outb(0x55, REG);
1685 ++ return 0;
1686 + }
1687 +
1688 + static inline void
1689 + superio_exit(void)
1690 + {
1691 + outb(0xAA, REG);
1692 ++ release_region(REG, 2);
1693 + }
1694 +
1695 + #define SUPERIO_REG_ACT 0x30
1696 +@@ -531,8 +536,12 @@ static int __init smsc47m1_find(struct smsc47m1_sio_data *sio_data)
1697 + {
1698 + u8 val;
1699 + unsigned short addr;
1700 ++ int err;
1701 ++
1702 ++ err = superio_enter();
1703 ++ if (err)
1704 ++ return err;
1705 +
1706 +- superio_enter();
1707 + val = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID);
1708 +
1709 + /*
1710 +@@ -608,13 +617,14 @@ static int __init smsc47m1_find(struct smsc47m1_sio_data *sio_data)
1711 + static void smsc47m1_restore(const struct smsc47m1_sio_data *sio_data)
1712 + {
1713 + if ((sio_data->activate & 0x01) == 0) {
1714 +- superio_enter();
1715 +- superio_select();
1716 +-
1717 +- pr_info("Disabling device\n");
1718 +- superio_outb(SUPERIO_REG_ACT, sio_data->activate);
1719 +-
1720 +- superio_exit();
1721 ++ if (!superio_enter()) {
1722 ++ superio_select();
1723 ++ pr_info("Disabling device\n");
1724 ++ superio_outb(SUPERIO_REG_ACT, sio_data->activate);
1725 ++ superio_exit();
1726 ++ } else {
1727 ++ pr_warn("Failed to disable device\n");
1728 ++ }
1729 + }
1730 + }
1731 +
1732 +diff --git a/drivers/hwmon/vt1211.c b/drivers/hwmon/vt1211.c
1733 +index 3a6bfa51cb94..95d5e8ec8b7f 100644
1734 +--- a/drivers/hwmon/vt1211.c
1735 ++++ b/drivers/hwmon/vt1211.c
1736 +@@ -226,15 +226,21 @@ static inline void superio_select(int sio_cip, int ldn)
1737 + outb(ldn, sio_cip + 1);
1738 + }
1739 +
1740 +-static inline void superio_enter(int sio_cip)
1741 ++static inline int superio_enter(int sio_cip)
1742 + {
1743 ++ if (!request_muxed_region(sio_cip, 2, DRVNAME))
1744 ++ return -EBUSY;
1745 ++
1746 + outb(0x87, sio_cip);
1747 + outb(0x87, sio_cip);
1748 ++
1749 ++ return 0;
1750 + }
1751 +
1752 + static inline void superio_exit(int sio_cip)
1753 + {
1754 + outb(0xaa, sio_cip);
1755 ++ release_region(sio_cip, 2);
1756 + }
1757 +
1758 + /* ---------------------------------------------------------------------
1759 +@@ -1282,11 +1288,14 @@ EXIT:
1760 +
1761 + static int __init vt1211_find(int sio_cip, unsigned short *address)
1762 + {
1763 +- int err = -ENODEV;
1764 ++ int err;
1765 + int devid;
1766 +
1767 +- superio_enter(sio_cip);
1768 ++ err = superio_enter(sio_cip);
1769 ++ if (err)
1770 ++ return err;
1771 +
1772 ++ err = -ENODEV;
1773 + devid = force_id ? force_id : superio_inb(sio_cip, SIO_VT1211_DEVID);
1774 + if (devid != SIO_VT1211_ID)
1775 + goto EXIT;
1776 +diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c
1777 +index a1d072ecb717..30f200ad6b97 100644
1778 +--- a/drivers/iio/adc/ad_sigma_delta.c
1779 ++++ b/drivers/iio/adc/ad_sigma_delta.c
1780 +@@ -62,7 +62,7 @@ int ad_sd_write_reg(struct ad_sigma_delta *sigma_delta, unsigned int reg,
1781 + struct spi_transfer t = {
1782 + .tx_buf = data,
1783 + .len = size + 1,
1784 +- .cs_change = sigma_delta->bus_locked,
1785 ++ .cs_change = sigma_delta->keep_cs_asserted,
1786 + };
1787 + struct spi_message m;
1788 + int ret;
1789 +@@ -217,6 +217,7 @@ static int ad_sd_calibrate(struct ad_sigma_delta *sigma_delta,
1790 +
1791 + spi_bus_lock(sigma_delta->spi->master);
1792 + sigma_delta->bus_locked = true;
1793 ++ sigma_delta->keep_cs_asserted = true;
1794 + reinit_completion(&sigma_delta->completion);
1795 +
1796 + ret = ad_sigma_delta_set_mode(sigma_delta, mode);
1797 +@@ -234,9 +235,10 @@ static int ad_sd_calibrate(struct ad_sigma_delta *sigma_delta,
1798 + ret = 0;
1799 + }
1800 + out:
1801 ++ sigma_delta->keep_cs_asserted = false;
1802 ++ ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_IDLE);
1803 + sigma_delta->bus_locked = false;
1804 + spi_bus_unlock(sigma_delta->spi->master);
1805 +- ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_IDLE);
1806 +
1807 + return ret;
1808 + }
1809 +@@ -288,6 +290,7 @@ int ad_sigma_delta_single_conversion(struct iio_dev *indio_dev,
1810 +
1811 + spi_bus_lock(sigma_delta->spi->master);
1812 + sigma_delta->bus_locked = true;
1813 ++ sigma_delta->keep_cs_asserted = true;
1814 + reinit_completion(&sigma_delta->completion);
1815 +
1816 + ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_SINGLE);
1817 +@@ -297,9 +300,6 @@ int ad_sigma_delta_single_conversion(struct iio_dev *indio_dev,
1818 + ret = wait_for_completion_interruptible_timeout(
1819 + &sigma_delta->completion, HZ);
1820 +
1821 +- sigma_delta->bus_locked = false;
1822 +- spi_bus_unlock(sigma_delta->spi->master);
1823 +-
1824 + if (ret == 0)
1825 + ret = -EIO;
1826 + if (ret < 0)
1827 +@@ -315,7 +315,10 @@ out:
1828 + sigma_delta->irq_dis = true;
1829 + }
1830 +
1831 ++ sigma_delta->keep_cs_asserted = false;
1832 + ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_IDLE);
1833 ++ sigma_delta->bus_locked = false;
1834 ++ spi_bus_unlock(sigma_delta->spi->master);
1835 + mutex_unlock(&indio_dev->mlock);
1836 +
1837 + if (ret)
1838 +@@ -352,6 +355,8 @@ static int ad_sd_buffer_postenable(struct iio_dev *indio_dev)
1839 +
1840 + spi_bus_lock(sigma_delta->spi->master);
1841 + sigma_delta->bus_locked = true;
1842 ++ sigma_delta->keep_cs_asserted = true;
1843 ++
1844 + ret = ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_CONTINUOUS);
1845 + if (ret)
1846 + goto err_unlock;
1847 +@@ -380,6 +385,7 @@ static int ad_sd_buffer_postdisable(struct iio_dev *indio_dev)
1848 + sigma_delta->irq_dis = true;
1849 + }
1850 +
1851 ++ sigma_delta->keep_cs_asserted = false;
1852 + ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_IDLE);
1853 +
1854 + sigma_delta->bus_locked = false;
1855 +diff --git a/drivers/iio/common/ssp_sensors/ssp_iio.c b/drivers/iio/common/ssp_sensors/ssp_iio.c
1856 +index 645f2e3975db..e38f704d88b7 100644
1857 +--- a/drivers/iio/common/ssp_sensors/ssp_iio.c
1858 ++++ b/drivers/iio/common/ssp_sensors/ssp_iio.c
1859 +@@ -81,7 +81,7 @@ int ssp_common_process_data(struct iio_dev *indio_dev, void *buf,
1860 + unsigned int len, int64_t timestamp)
1861 + {
1862 + __le32 time;
1863 +- int64_t calculated_time;
1864 ++ int64_t calculated_time = 0;
1865 + struct ssp_sensor_data *spd = iio_priv(indio_dev);
1866 +
1867 + if (indio_dev->scan_bytes == 0)
1868 +diff --git a/drivers/iio/magnetometer/hmc5843_i2c.c b/drivers/iio/magnetometer/hmc5843_i2c.c
1869 +index 3de7f4426ac4..86abba5827a2 100644
1870 +--- a/drivers/iio/magnetometer/hmc5843_i2c.c
1871 ++++ b/drivers/iio/magnetometer/hmc5843_i2c.c
1872 +@@ -58,8 +58,13 @@ static const struct regmap_config hmc5843_i2c_regmap_config = {
1873 + static int hmc5843_i2c_probe(struct i2c_client *cli,
1874 + const struct i2c_device_id *id)
1875 + {
1876 ++ struct regmap *regmap = devm_regmap_init_i2c(cli,
1877 ++ &hmc5843_i2c_regmap_config);
1878 ++ if (IS_ERR(regmap))
1879 ++ return PTR_ERR(regmap);
1880 ++
1881 + return hmc5843_common_probe(&cli->dev,
1882 +- devm_regmap_init_i2c(cli, &hmc5843_i2c_regmap_config),
1883 ++ regmap,
1884 + id->driver_data, id->name);
1885 + }
1886 +
1887 +diff --git a/drivers/iio/magnetometer/hmc5843_spi.c b/drivers/iio/magnetometer/hmc5843_spi.c
1888 +index 535f03a70d63..79b2b707f90e 100644
1889 +--- a/drivers/iio/magnetometer/hmc5843_spi.c
1890 ++++ b/drivers/iio/magnetometer/hmc5843_spi.c
1891 +@@ -58,6 +58,7 @@ static const struct regmap_config hmc5843_spi_regmap_config = {
1892 + static int hmc5843_spi_probe(struct spi_device *spi)
1893 + {
1894 + int ret;
1895 ++ struct regmap *regmap;
1896 + const struct spi_device_id *id = spi_get_device_id(spi);
1897 +
1898 + spi->mode = SPI_MODE_3;
1899 +@@ -67,8 +68,12 @@ static int hmc5843_spi_probe(struct spi_device *spi)
1900 + if (ret)
1901 + return ret;
1902 +
1903 ++ regmap = devm_regmap_init_spi(spi, &hmc5843_spi_regmap_config);
1904 ++ if (IS_ERR(regmap))
1905 ++ return PTR_ERR(regmap);
1906 ++
1907 + return hmc5843_common_probe(&spi->dev,
1908 +- devm_regmap_init_spi(spi, &hmc5843_spi_regmap_config),
1909 ++ regmap,
1910 + id->driver_data, id->name);
1911 + }
1912 +
1913 +diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
1914 +index e17f11782821..d87f08cd78ad 100644
1915 +--- a/drivers/infiniband/hw/cxgb4/cm.c
1916 ++++ b/drivers/infiniband/hw/cxgb4/cm.c
1917 +@@ -456,6 +456,8 @@ static struct sk_buff *get_skb(struct sk_buff *skb, int len, gfp_t gfp)
1918 + skb_reset_transport_header(skb);
1919 + } else {
1920 + skb = alloc_skb(len, gfp);
1921 ++ if (!skb)
1922 ++ return NULL;
1923 + }
1924 + t4_set_arp_err_handler(skb, NULL, NULL);
1925 + return skb;
1926 +diff --git a/drivers/infiniband/hw/hfi1/init.c b/drivers/infiniband/hw/hfi1/init.c
1927 +index b7481701542e..27e7de4c4a34 100644
1928 +--- a/drivers/infiniband/hw/hfi1/init.c
1929 ++++ b/drivers/infiniband/hw/hfi1/init.c
1930 +@@ -769,7 +769,8 @@ static int create_workqueues(struct hfi1_devdata *dd)
1931 + ppd->hfi1_wq =
1932 + alloc_workqueue(
1933 + "hfi%d_%d",
1934 +- WQ_SYSFS | WQ_HIGHPRI | WQ_CPU_INTENSIVE,
1935 ++ WQ_SYSFS | WQ_HIGHPRI | WQ_CPU_INTENSIVE |
1936 ++ WQ_MEM_RECLAIM,
1937 + HFI1_MAX_ACTIVE_WORKQUEUE_ENTRIES,
1938 + dd->unit, pidx);
1939 + if (!ppd->hfi1_wq)
1940 +diff --git a/drivers/infiniband/hw/hns/hns_roce_ah.c b/drivers/infiniband/hw/hns/hns_roce_ah.c
1941 +index d545302b8ef8..0cdd4492811b 100644
1942 +--- a/drivers/infiniband/hw/hns/hns_roce_ah.c
1943 ++++ b/drivers/infiniband/hw/hns/hns_roce_ah.c
1944 +@@ -91,7 +91,7 @@ struct ib_ah *hns_roce_create_ah(struct ib_pd *ibpd,
1945 + HNS_ROCE_VLAN_SL_BIT_MASK) <<
1946 + HNS_ROCE_VLAN_SL_SHIFT;
1947 +
1948 +- ah->av.port_pd = cpu_to_be32(to_hr_pd(ibpd)->pdn |
1949 ++ ah->av.port_pd = cpu_to_le32(to_hr_pd(ibpd)->pdn |
1950 + (rdma_ah_get_port_num(ah_attr) <<
1951 + HNS_ROCE_PORT_NUM_SHIFT));
1952 + ah->av.gid_index = grh->sgid_index;
1953 +diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c
1954 +index 8c13a9036d07..ada94a01e142 100644
1955 +--- a/drivers/md/bcache/alloc.c
1956 ++++ b/drivers/md/bcache/alloc.c
1957 +@@ -325,10 +325,11 @@ static int bch_allocator_thread(void *arg)
1958 + * possibly issue discards to them, then we add the bucket to
1959 + * the free list:
1960 + */
1961 +- while (!fifo_empty(&ca->free_inc)) {
1962 ++ while (1) {
1963 + long bucket;
1964 +
1965 +- fifo_pop(&ca->free_inc, bucket);
1966 ++ if (!fifo_pop(&ca->free_inc, bucket))
1967 ++ break;
1968 +
1969 + if (ca->discard) {
1970 + mutex_unlock(&ca->set->bucket_lock);
1971 +diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
1972 +index c02394c3181f..6394be5ee9a8 100644
1973 +--- a/drivers/md/bcache/journal.c
1974 ++++ b/drivers/md/bcache/journal.c
1975 +@@ -310,6 +310,18 @@ void bch_journal_mark(struct cache_set *c, struct list_head *list)
1976 + }
1977 + }
1978 +
1979 ++bool is_discard_enabled(struct cache_set *s)
1980 ++{
1981 ++ struct cache *ca;
1982 ++ unsigned int i;
1983 ++
1984 ++ for_each_cache(ca, s, i)
1985 ++ if (ca->discard)
1986 ++ return true;
1987 ++
1988 ++ return false;
1989 ++}
1990 ++
1991 + int bch_journal_replay(struct cache_set *s, struct list_head *list)
1992 + {
1993 + int ret = 0, keys = 0, entries = 0;
1994 +@@ -323,9 +335,17 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list)
1995 + list_for_each_entry(i, list, list) {
1996 + BUG_ON(i->pin && atomic_read(i->pin) != 1);
1997 +
1998 +- cache_set_err_on(n != i->j.seq, s,
1999 +-"bcache: journal entries %llu-%llu missing! (replaying %llu-%llu)",
2000 +- n, i->j.seq - 1, start, end);
2001 ++ if (n != i->j.seq) {
2002 ++ if (n == start && is_discard_enabled(s))
2003 ++ pr_info("bcache: journal entries %llu-%llu may be discarded! (replaying %llu-%llu)",
2004 ++ n, i->j.seq - 1, start, end);
2005 ++ else {
2006 ++ pr_err("bcache: journal entries %llu-%llu missing! (replaying %llu-%llu)",
2007 ++ n, i->j.seq - 1, start, end);
2008 ++ ret = -EIO;
2009 ++ goto err;
2010 ++ }
2011 ++ }
2012 +
2013 + for (k = i->j.start;
2014 + k < bset_bkey_last(&i->j);
2015 +diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
2016 +index 175bab2d7206..85a5afe01d39 100644
2017 +--- a/drivers/md/bcache/super.c
2018 ++++ b/drivers/md/bcache/super.c
2019 +@@ -1560,7 +1560,7 @@ err:
2020 + return NULL;
2021 + }
2022 +
2023 +-static void run_cache_set(struct cache_set *c)
2024 ++static int run_cache_set(struct cache_set *c)
2025 + {
2026 + const char *err = "cannot allocate memory";
2027 + struct cached_dev *dc, *t;
2028 +@@ -1652,7 +1652,9 @@ static void run_cache_set(struct cache_set *c)
2029 + if (j->version < BCACHE_JSET_VERSION_UUID)
2030 + __uuid_write(c);
2031 +
2032 +- bch_journal_replay(c, &journal);
2033 ++ err = "bcache: replay journal failed";
2034 ++ if (bch_journal_replay(c, &journal))
2035 ++ goto err;
2036 + } else {
2037 + pr_notice("invalidating existing data");
2038 +
2039 +@@ -1720,11 +1722,13 @@ static void run_cache_set(struct cache_set *c)
2040 + flash_devs_run(c);
2041 +
2042 + set_bit(CACHE_SET_RUNNING, &c->flags);
2043 +- return;
2044 ++ return 0;
2045 + err:
2046 + closure_sync(&cl);
2047 + /* XXX: test this, it's broken */
2048 + bch_cache_set_error(c, "%s", err);
2049 ++
2050 ++ return -EIO;
2051 + }
2052 +
2053 + static bool can_attach_cache(struct cache *ca, struct cache_set *c)
2054 +@@ -1788,8 +1792,11 @@ found:
2055 + ca->set->cache[ca->sb.nr_this_dev] = ca;
2056 + c->cache_by_alloc[c->caches_loaded++] = ca;
2057 +
2058 +- if (c->caches_loaded == c->sb.nr_in_set)
2059 +- run_cache_set(c);
2060 ++ if (c->caches_loaded == c->sb.nr_in_set) {
2061 ++ err = "failed to run cache set";
2062 ++ if (run_cache_set(c) < 0)
2063 ++ goto err;
2064 ++ }
2065 +
2066 + return NULL;
2067 + err:
2068 +diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c
2069 +index 65d157fe76d1..b4bd1af34745 100644
2070 +--- a/drivers/media/dvb-frontends/m88ds3103.c
2071 ++++ b/drivers/media/dvb-frontends/m88ds3103.c
2072 +@@ -309,6 +309,9 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
2073 + u16 u16tmp;
2074 + u32 tuner_frequency_khz, target_mclk;
2075 + s32 s32tmp;
2076 ++ static const struct reg_sequence reset_buf[] = {
2077 ++ {0x07, 0x80}, {0x07, 0x00}
2078 ++ };
2079 +
2080 + dev_dbg(&client->dev,
2081 + "delivery_system=%d modulation=%d frequency=%u symbol_rate=%d inversion=%d pilot=%d rolloff=%d\n",
2082 +@@ -321,11 +324,7 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
2083 + }
2084 +
2085 + /* reset */
2086 +- ret = regmap_write(dev->regmap, 0x07, 0x80);
2087 +- if (ret)
2088 +- goto err;
2089 +-
2090 +- ret = regmap_write(dev->regmap, 0x07, 0x00);
2091 ++ ret = regmap_multi_reg_write(dev->regmap, reset_buf, 2);
2092 + if (ret)
2093 + goto err;
2094 +
2095 +diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
2096 +index 122dd6c5eb38..ce23f436e130 100644
2097 +--- a/drivers/media/i2c/ov2659.c
2098 ++++ b/drivers/media/i2c/ov2659.c
2099 +@@ -1117,8 +1117,10 @@ static int ov2659_set_fmt(struct v4l2_subdev *sd,
2100 + if (ov2659_formats[index].code == mf->code)
2101 + break;
2102 +
2103 +- if (index < 0)
2104 +- return -EINVAL;
2105 ++ if (index < 0) {
2106 ++ index = 0;
2107 ++ mf->code = ov2659_formats[index].code;
2108 ++ }
2109 +
2110 + mf->colorspace = V4L2_COLORSPACE_SRGB;
2111 + mf->field = V4L2_FIELD_NONE;
2112 +diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
2113 +index 07bc819f5819..025869eec2ac 100644
2114 +--- a/drivers/media/i2c/ov6650.c
2115 ++++ b/drivers/media/i2c/ov6650.c
2116 +@@ -822,9 +822,16 @@ static int ov6650_video_probe(struct i2c_client *client)
2117 + u8 pidh, pidl, midh, midl;
2118 + int ret;
2119 +
2120 ++ priv->clk = v4l2_clk_get(&client->dev, NULL);
2121 ++ if (IS_ERR(priv->clk)) {
2122 ++ ret = PTR_ERR(priv->clk);
2123 ++ dev_err(&client->dev, "v4l2_clk request err: %d\n", ret);
2124 ++ return ret;
2125 ++ }
2126 ++
2127 + ret = ov6650_s_power(&priv->subdev, 1);
2128 + if (ret < 0)
2129 +- return ret;
2130 ++ goto eclkput;
2131 +
2132 + msleep(20);
2133 +
2134 +@@ -861,6 +868,11 @@ static int ov6650_video_probe(struct i2c_client *client)
2135 +
2136 + done:
2137 + ov6650_s_power(&priv->subdev, 0);
2138 ++ if (!ret)
2139 ++ return 0;
2140 ++eclkput:
2141 ++ v4l2_clk_put(priv->clk);
2142 ++
2143 + return ret;
2144 + }
2145 +
2146 +@@ -1006,18 +1018,9 @@ static int ov6650_probe(struct i2c_client *client,
2147 + priv->code = MEDIA_BUS_FMT_YUYV8_2X8;
2148 + priv->colorspace = V4L2_COLORSPACE_JPEG;
2149 +
2150 +- priv->clk = v4l2_clk_get(&client->dev, NULL);
2151 +- if (IS_ERR(priv->clk)) {
2152 +- ret = PTR_ERR(priv->clk);
2153 +- goto eclkget;
2154 +- }
2155 +-
2156 + ret = ov6650_video_probe(client);
2157 +- if (ret) {
2158 +- v4l2_clk_put(priv->clk);
2159 +-eclkget:
2160 ++ if (ret)
2161 + v4l2_ctrl_handler_free(&priv->hdl);
2162 +- }
2163 +
2164 + return ret;
2165 + }
2166 +diff --git a/drivers/media/pci/saa7146/hexium_gemini.c b/drivers/media/pci/saa7146/hexium_gemini.c
2167 +index f708cab01fef..934332f1fd8e 100644
2168 +--- a/drivers/media/pci/saa7146/hexium_gemini.c
2169 ++++ b/drivers/media/pci/saa7146/hexium_gemini.c
2170 +@@ -270,9 +270,8 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d
2171 + /* enable i2c-port pins */
2172 + saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26));
2173 +
2174 +- hexium->i2c_adapter = (struct i2c_adapter) {
2175 +- .name = "hexium gemini",
2176 +- };
2177 ++ strscpy(hexium->i2c_adapter.name, "hexium gemini",
2178 ++ sizeof(hexium->i2c_adapter.name));
2179 + saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480);
2180 + if (i2c_add_adapter(&hexium->i2c_adapter) < 0) {
2181 + DEB_S("cannot register i2c-device. skipping.\n");
2182 +diff --git a/drivers/media/pci/saa7146/hexium_orion.c b/drivers/media/pci/saa7146/hexium_orion.c
2183 +index 01f01580c7ca..cb71653a6669 100644
2184 +--- a/drivers/media/pci/saa7146/hexium_orion.c
2185 ++++ b/drivers/media/pci/saa7146/hexium_orion.c
2186 +@@ -232,9 +232,8 @@ static int hexium_probe(struct saa7146_dev *dev)
2187 + saa7146_write(dev, DD1_STREAM_B, 0x00000000);
2188 + saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
2189 +
2190 +- hexium->i2c_adapter = (struct i2c_adapter) {
2191 +- .name = "hexium orion",
2192 +- };
2193 ++ strscpy(hexium->i2c_adapter.name, "hexium orion",
2194 ++ sizeof(hexium->i2c_adapter.name));
2195 + saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480);
2196 + if (i2c_add_adapter(&hexium->i2c_adapter) < 0) {
2197 + DEB_S("cannot register i2c-device. skipping.\n");
2198 +diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c
2199 +index 3457a5f1c8a8..6eee55430d46 100644
2200 +--- a/drivers/media/platform/coda/coda-bit.c
2201 ++++ b/drivers/media/platform/coda/coda-bit.c
2202 +@@ -1948,6 +1948,9 @@ static int coda_prepare_decode(struct coda_ctx *ctx)
2203 + /* Clear decode success flag */
2204 + coda_write(dev, 0, CODA_RET_DEC_PIC_SUCCESS);
2205 +
2206 ++ /* Clear error return value */
2207 ++ coda_write(dev, 0, CODA_RET_DEC_PIC_ERR_MB);
2208 ++
2209 + trace_coda_dec_pic_run(ctx, meta);
2210 +
2211 + coda_command_async(ctx, CODA_COMMAND_PIC_RUN);
2212 +diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
2213 +index 35ba6f211b79..4281f3f76ab1 100644
2214 +--- a/drivers/media/platform/stm32/stm32-dcmi.c
2215 ++++ b/drivers/media/platform/stm32/stm32-dcmi.c
2216 +@@ -775,6 +775,9 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f,
2217 +
2218 + sd_fmt = find_format_by_fourcc(dcmi, pix->pixelformat);
2219 + if (!sd_fmt) {
2220 ++ if (!dcmi->num_of_sd_formats)
2221 ++ return -ENODATA;
2222 ++
2223 + sd_fmt = dcmi->sd_formats[dcmi->num_of_sd_formats - 1];
2224 + pix->pixelformat = sd_fmt->fourcc;
2225 + }
2226 +@@ -946,6 +949,9 @@ static int dcmi_set_sensor_format(struct stm32_dcmi *dcmi,
2227 +
2228 + sd_fmt = find_format_by_fourcc(dcmi, pix->pixelformat);
2229 + if (!sd_fmt) {
2230 ++ if (!dcmi->num_of_sd_formats)
2231 ++ return -ENODATA;
2232 ++
2233 + sd_fmt = dcmi->sd_formats[dcmi->num_of_sd_formats - 1];
2234 + pix->pixelformat = sd_fmt->fourcc;
2235 + }
2236 +diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c
2237 +index ee89ad76bee2..eedc0b99a891 100644
2238 +--- a/drivers/media/platform/video-mux.c
2239 ++++ b/drivers/media/platform/video-mux.c
2240 +@@ -242,9 +242,14 @@ static int video_mux_probe(struct platform_device *pdev)
2241 + vmux->active = -1;
2242 + vmux->pads = devm_kcalloc(dev, num_pads, sizeof(*vmux->pads),
2243 + GFP_KERNEL);
2244 ++ if (!vmux->pads)
2245 ++ return -ENOMEM;
2246 ++
2247 + vmux->format_mbus = devm_kcalloc(dev, num_pads,
2248 + sizeof(*vmux->format_mbus),
2249 + GFP_KERNEL);
2250 ++ if (!vmux->format_mbus)
2251 ++ return -ENOMEM;
2252 +
2253 + for (i = 0; i < num_pads - 1; i++)
2254 + vmux->pads[i].flags = MEDIA_PAD_FL_SINK;
2255 +diff --git a/drivers/media/platform/vimc/vimc-core.c b/drivers/media/platform/vimc/vimc-core.c
2256 +index 51c0eee61ca6..57e5d6a020b0 100644
2257 +--- a/drivers/media/platform/vimc/vimc-core.c
2258 ++++ b/drivers/media/platform/vimc/vimc-core.c
2259 +@@ -302,6 +302,8 @@ static int vimc_probe(struct platform_device *pdev)
2260 +
2261 + dev_dbg(&pdev->dev, "probe");
2262 +
2263 ++ memset(&vimc->mdev, 0, sizeof(vimc->mdev));
2264 ++
2265 + /* Create platform_device for each entity in the topology*/
2266 + vimc->subdevs = devm_kcalloc(&vimc->pdev.dev, vimc->pipe_cfg->num_ents,
2267 + sizeof(*vimc->subdevs), GFP_KERNEL);
2268 +diff --git a/drivers/media/platform/vimc/vimc-streamer.c b/drivers/media/platform/vimc/vimc-streamer.c
2269 +index fcc897fb247b..392754c18046 100644
2270 +--- a/drivers/media/platform/vimc/vimc-streamer.c
2271 ++++ b/drivers/media/platform/vimc/vimc-streamer.c
2272 +@@ -120,7 +120,6 @@ static int vimc_streamer_thread(void *data)
2273 + int i;
2274 +
2275 + set_freezable();
2276 +- set_current_state(TASK_UNINTERRUPTIBLE);
2277 +
2278 + for (;;) {
2279 + try_to_freeze();
2280 +@@ -137,6 +136,7 @@ static int vimc_streamer_thread(void *data)
2281 + break;
2282 + }
2283 + //wait for 60hz
2284 ++ set_current_state(TASK_UNINTERRUPTIBLE);
2285 + schedule_timeout(HZ / 60);
2286 + }
2287 +
2288 +diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c b/drivers/media/platform/vivid/vivid-vid-cap.c
2289 +index a7a366093524..4ca3d600aa84 100644
2290 +--- a/drivers/media/platform/vivid/vivid-vid-cap.c
2291 ++++ b/drivers/media/platform/vivid/vivid-vid-cap.c
2292 +@@ -1007,7 +1007,7 @@ int vivid_vid_cap_s_selection(struct file *file, void *fh, struct v4l2_selection
2293 + v4l2_rect_map_inside(&s->r, &dev->fmt_cap_rect);
2294 + if (dev->bitmap_cap && (compose->width != s->r.width ||
2295 + compose->height != s->r.height)) {
2296 +- kfree(dev->bitmap_cap);
2297 ++ vfree(dev->bitmap_cap);
2298 + dev->bitmap_cap = NULL;
2299 + }
2300 + *compose = s->r;
2301 +diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
2302 +index ab3428bf63fe..26895ae42fcf 100644
2303 +--- a/drivers/media/radio/wl128x/fmdrv_common.c
2304 ++++ b/drivers/media/radio/wl128x/fmdrv_common.c
2305 +@@ -489,7 +489,8 @@ int fmc_send_cmd(struct fmdev *fmdev, u8 fm_op, u16 type, void *payload,
2306 + return -EIO;
2307 + }
2308 + /* Send response data to caller */
2309 +- if (response != NULL && response_len != NULL && evt_hdr->dlen) {
2310 ++ if (response != NULL && response_len != NULL && evt_hdr->dlen &&
2311 ++ evt_hdr->dlen <= payload_len) {
2312 + /* Skip header info and copy only response data */
2313 + skb_pull(skb, sizeof(struct fm_event_msg_hdr));
2314 + memcpy(response, skb->data, evt_hdr->dlen);
2315 +@@ -583,6 +584,8 @@ static void fm_irq_handle_flag_getcmd_resp(struct fmdev *fmdev)
2316 + return;
2317 +
2318 + fm_evt_hdr = (void *)skb->data;
2319 ++ if (fm_evt_hdr->dlen > sizeof(fmdev->irq_info.flag))
2320 ++ return;
2321 +
2322 + /* Skip header info and copy only response data */
2323 + skb_pull(skb, sizeof(struct fm_event_msg_hdr));
2324 +@@ -1308,7 +1311,7 @@ static int load_default_rx_configuration(struct fmdev *fmdev)
2325 + static int fm_power_up(struct fmdev *fmdev, u8 mode)
2326 + {
2327 + u16 payload;
2328 +- __be16 asic_id, asic_ver;
2329 ++ __be16 asic_id = 0, asic_ver = 0;
2330 + int resp_len, ret;
2331 + u8 fw_name[50];
2332 +
2333 +diff --git a/drivers/media/rc/serial_ir.c b/drivers/media/rc/serial_ir.c
2334 +index 8b66926bc16a..842c121dca2d 100644
2335 +--- a/drivers/media/rc/serial_ir.c
2336 ++++ b/drivers/media/rc/serial_ir.c
2337 +@@ -774,8 +774,6 @@ static void serial_ir_exit(void)
2338 +
2339 + static int __init serial_ir_init_module(void)
2340 + {
2341 +- int result;
2342 +-
2343 + switch (type) {
2344 + case IR_HOMEBREW:
2345 + case IR_IRDEO:
2346 +@@ -803,12 +801,7 @@ static int __init serial_ir_init_module(void)
2347 + if (sense != -1)
2348 + sense = !!sense;
2349 +
2350 +- result = serial_ir_init();
2351 +- if (!result)
2352 +- return 0;
2353 +-
2354 +- serial_ir_exit();
2355 +- return result;
2356 ++ return serial_ir_init();
2357 + }
2358 +
2359 + static void __exit serial_ir_exit_module(void)
2360 +diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
2361 +index 9342402b92f7..067f46c4f61a 100644
2362 +--- a/drivers/media/usb/au0828/au0828-video.c
2363 ++++ b/drivers/media/usb/au0828/au0828-video.c
2364 +@@ -758,6 +758,9 @@ static int au0828_analog_stream_enable(struct au0828_dev *d)
2365 +
2366 + dprintk(1, "au0828_analog_stream_enable called\n");
2367 +
2368 ++ if (test_bit(DEV_DISCONNECTED, &d->dev_state))
2369 ++ return -ENODEV;
2370 ++
2371 + iface = usb_ifnum_to_if(d->usbdev, 0);
2372 + if (iface && iface->cur_altsetting->desc.bAlternateSetting != 5) {
2373 + dprintk(1, "Changing intf#0 to alt 5\n");
2374 +@@ -839,9 +842,9 @@ int au0828_start_analog_streaming(struct vb2_queue *vq, unsigned int count)
2375 + return rc;
2376 + }
2377 +
2378 ++ v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 1);
2379 ++
2380 + if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
2381 +- v4l2_device_call_all(&dev->v4l2_dev, 0, video,
2382 +- s_stream, 1);
2383 + dev->vid_timeout_running = 1;
2384 + mod_timer(&dev->vid_timeout, jiffies + (HZ / 10));
2385 + } else if (vq->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
2386 +@@ -861,10 +864,11 @@ static void au0828_stop_streaming(struct vb2_queue *vq)
2387 +
2388 + dprintk(1, "au0828_stop_streaming called %d\n", dev->streaming_users);
2389 +
2390 +- if (dev->streaming_users-- == 1)
2391 ++ if (dev->streaming_users-- == 1) {
2392 + au0828_uninit_isoc(dev);
2393 ++ v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 0);
2394 ++ }
2395 +
2396 +- v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 0);
2397 + dev->vid_timeout_running = 0;
2398 + del_timer_sync(&dev->vid_timeout);
2399 +
2400 +@@ -893,8 +897,10 @@ void au0828_stop_vbi_streaming(struct vb2_queue *vq)
2401 + dprintk(1, "au0828_stop_vbi_streaming called %d\n",
2402 + dev->streaming_users);
2403 +
2404 +- if (dev->streaming_users-- == 1)
2405 ++ if (dev->streaming_users-- == 1) {
2406 + au0828_uninit_isoc(dev);
2407 ++ v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 0);
2408 ++ }
2409 +
2410 + spin_lock_irqsave(&dev->slock, flags);
2411 + if (dev->isoc_ctl.vbi_buf != NULL) {
2412 +diff --git a/drivers/media/usb/cpia2/cpia2_v4l.c b/drivers/media/usb/cpia2/cpia2_v4l.c
2413 +index a1c59f19cf2d..1e3da414319b 100644
2414 +--- a/drivers/media/usb/cpia2/cpia2_v4l.c
2415 ++++ b/drivers/media/usb/cpia2/cpia2_v4l.c
2416 +@@ -1244,8 +1244,7 @@ static int __init cpia2_init(void)
2417 + LOG("%s v%s\n",
2418 + ABOUT, CPIA_VERSION);
2419 + check_parameters();
2420 +- cpia2_usb_init();
2421 +- return 0;
2422 ++ return cpia2_usb_init();
2423 + }
2424 +
2425 +
2426 +diff --git a/drivers/media/usb/go7007/go7007-fw.c b/drivers/media/usb/go7007/go7007-fw.c
2427 +index 60bf5f0644d1..a5efcd4f7b4f 100644
2428 +--- a/drivers/media/usb/go7007/go7007-fw.c
2429 ++++ b/drivers/media/usb/go7007/go7007-fw.c
2430 +@@ -1499,8 +1499,8 @@ static int modet_to_package(struct go7007 *go, __le16 *code, int space)
2431 + return cnt;
2432 + }
2433 +
2434 +-static int do_special(struct go7007 *go, u16 type, __le16 *code, int space,
2435 +- int *framelen)
2436 ++static noinline_for_stack int do_special(struct go7007 *go, u16 type,
2437 ++ __le16 *code, int space, int *framelen)
2438 + {
2439 + switch (type) {
2440 + case SPECIAL_FRM_HEAD:
2441 +diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
2442 +index 44975061b953..ddededc4ced4 100644
2443 +--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
2444 ++++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
2445 +@@ -666,6 +666,8 @@ static int ctrl_get_input(struct pvr2_ctrl *cptr,int *vp)
2446 +
2447 + static int ctrl_check_input(struct pvr2_ctrl *cptr,int v)
2448 + {
2449 ++ if (v < 0 || v > PVR2_CVAL_INPUT_MAX)
2450 ++ return 0;
2451 + return ((1 << v) & cptr->hdw->input_allowed_mask) != 0;
2452 + }
2453 +
2454 +diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.h b/drivers/media/usb/pvrusb2/pvrusb2-hdw.h
2455 +index 25648add77e5..bd2b7a67b732 100644
2456 +--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.h
2457 ++++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.h
2458 +@@ -50,6 +50,7 @@
2459 + #define PVR2_CVAL_INPUT_COMPOSITE 2
2460 + #define PVR2_CVAL_INPUT_SVIDEO 3
2461 + #define PVR2_CVAL_INPUT_RADIO 4
2462 ++#define PVR2_CVAL_INPUT_MAX PVR2_CVAL_INPUT_RADIO
2463 +
2464 + enum pvr2_config {
2465 + pvr2_config_empty, /* No configuration */
2466 +diff --git a/drivers/mmc/core/pwrseq_emmc.c b/drivers/mmc/core/pwrseq_emmc.c
2467 +index efb8a7965dd4..154f4204d58c 100644
2468 +--- a/drivers/mmc/core/pwrseq_emmc.c
2469 ++++ b/drivers/mmc/core/pwrseq_emmc.c
2470 +@@ -30,19 +30,14 @@ struct mmc_pwrseq_emmc {
2471 +
2472 + #define to_pwrseq_emmc(p) container_of(p, struct mmc_pwrseq_emmc, pwrseq)
2473 +
2474 +-static void __mmc_pwrseq_emmc_reset(struct mmc_pwrseq_emmc *pwrseq)
2475 +-{
2476 +- gpiod_set_value(pwrseq->reset_gpio, 1);
2477 +- udelay(1);
2478 +- gpiod_set_value(pwrseq->reset_gpio, 0);
2479 +- udelay(200);
2480 +-}
2481 +-
2482 + static void mmc_pwrseq_emmc_reset(struct mmc_host *host)
2483 + {
2484 + struct mmc_pwrseq_emmc *pwrseq = to_pwrseq_emmc(host->pwrseq);
2485 +
2486 +- __mmc_pwrseq_emmc_reset(pwrseq);
2487 ++ gpiod_set_value_cansleep(pwrseq->reset_gpio, 1);
2488 ++ udelay(1);
2489 ++ gpiod_set_value_cansleep(pwrseq->reset_gpio, 0);
2490 ++ udelay(200);
2491 + }
2492 +
2493 + static int mmc_pwrseq_emmc_reset_nb(struct notifier_block *this,
2494 +@@ -50,8 +45,11 @@ static int mmc_pwrseq_emmc_reset_nb(struct notifier_block *this,
2495 + {
2496 + struct mmc_pwrseq_emmc *pwrseq = container_of(this,
2497 + struct mmc_pwrseq_emmc, reset_nb);
2498 ++ gpiod_set_value(pwrseq->reset_gpio, 1);
2499 ++ udelay(1);
2500 ++ gpiod_set_value(pwrseq->reset_gpio, 0);
2501 ++ udelay(200);
2502 +
2503 +- __mmc_pwrseq_emmc_reset(pwrseq);
2504 + return NOTIFY_DONE;
2505 + }
2506 +
2507 +@@ -72,14 +70,18 @@ static int mmc_pwrseq_emmc_probe(struct platform_device *pdev)
2508 + if (IS_ERR(pwrseq->reset_gpio))
2509 + return PTR_ERR(pwrseq->reset_gpio);
2510 +
2511 +- /*
2512 +- * register reset handler to ensure emmc reset also from
2513 +- * emergency_reboot(), priority 255 is the highest priority
2514 +- * so it will be executed before any system reboot handler.
2515 +- */
2516 +- pwrseq->reset_nb.notifier_call = mmc_pwrseq_emmc_reset_nb;
2517 +- pwrseq->reset_nb.priority = 255;
2518 +- register_restart_handler(&pwrseq->reset_nb);
2519 ++ if (!gpiod_cansleep(pwrseq->reset_gpio)) {
2520 ++ /*
2521 ++ * register reset handler to ensure emmc reset also from
2522 ++ * emergency_reboot(), priority 255 is the highest priority
2523 ++ * so it will be executed before any system reboot handler.
2524 ++ */
2525 ++ pwrseq->reset_nb.notifier_call = mmc_pwrseq_emmc_reset_nb;
2526 ++ pwrseq->reset_nb.priority = 255;
2527 ++ register_restart_handler(&pwrseq->reset_nb);
2528 ++ } else {
2529 ++ dev_notice(dev, "EMMC reset pin tied to a sleepy GPIO driver; reset on emergency-reboot disabled\n");
2530 ++ }
2531 +
2532 + pwrseq->pwrseq.ops = &mmc_pwrseq_emmc_ops;
2533 + pwrseq->pwrseq.dev = dev;
2534 +diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
2535 +index eb9de2134967..fe2ef52135b6 100644
2536 +--- a/drivers/mmc/core/sd.c
2537 ++++ b/drivers/mmc/core/sd.c
2538 +@@ -216,6 +216,14 @@ static int mmc_decode_scr(struct mmc_card *card)
2539 +
2540 + if (scr->sda_spec3)
2541 + scr->cmds = UNSTUFF_BITS(resp, 32, 2);
2542 ++
2543 ++ /* SD Spec says: any SD Card shall set at least bits 0 and 2 */
2544 ++ if (!(scr->bus_widths & SD_SCR_BUS_WIDTH_1) ||
2545 ++ !(scr->bus_widths & SD_SCR_BUS_WIDTH_4)) {
2546 ++ pr_err("%s: invalid bus width\n", mmc_hostname(card->host));
2547 ++ return -EINVAL;
2548 ++ }
2549 ++
2550 + return 0;
2551 + }
2552 +
2553 +diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
2554 +index 67f6bd24a9d0..ea254d00541f 100644
2555 +--- a/drivers/mmc/host/mmc_spi.c
2556 ++++ b/drivers/mmc/host/mmc_spi.c
2557 +@@ -819,6 +819,10 @@ mmc_spi_readblock(struct mmc_spi_host *host, struct spi_transfer *t,
2558 + }
2559 +
2560 + status = spi_sync_locked(spi, &host->m);
2561 ++ if (status < 0) {
2562 ++ dev_dbg(&spi->dev, "read error %d\n", status);
2563 ++ return status;
2564 ++ }
2565 +
2566 + if (host->dma_dev) {
2567 + dma_sync_single_for_cpu(host->dma_dev,
2568 +diff --git a/drivers/mmc/host/sdhci-iproc.c b/drivers/mmc/host/sdhci-iproc.c
2569 +index cecffcbd3ca8..1e2417ec1ab4 100644
2570 +--- a/drivers/mmc/host/sdhci-iproc.c
2571 ++++ b/drivers/mmc/host/sdhci-iproc.c
2572 +@@ -185,7 +185,8 @@ static const struct sdhci_ops sdhci_iproc_32only_ops = {
2573 + };
2574 +
2575 + static const struct sdhci_pltfm_data sdhci_iproc_cygnus_pltfm_data = {
2576 +- .quirks = SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK,
2577 ++ .quirks = SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK |
2578 ++ SDHCI_QUIRK_NO_HISPD_BIT,
2579 + .quirks2 = SDHCI_QUIRK2_ACMD23_BROKEN | SDHCI_QUIRK2_HOST_OFF_CARD_ON,
2580 + .ops = &sdhci_iproc_32only_ops,
2581 + };
2582 +@@ -208,7 +209,8 @@ static const struct sdhci_iproc_data iproc_cygnus_data = {
2583 +
2584 + static const struct sdhci_pltfm_data sdhci_iproc_pltfm_data = {
2585 + .quirks = SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK |
2586 +- SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12,
2587 ++ SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12 |
2588 ++ SDHCI_QUIRK_NO_HISPD_BIT,
2589 + .quirks2 = SDHCI_QUIRK2_ACMD23_BROKEN,
2590 + .ops = &sdhci_iproc_ops,
2591 + };
2592 +diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
2593 +index 7b7d077e40fd..bcfa84aa2113 100644
2594 +--- a/drivers/mmc/host/sdhci-of-esdhc.c
2595 ++++ b/drivers/mmc/host/sdhci-of-esdhc.c
2596 +@@ -610,6 +610,9 @@ static void esdhc_reset(struct sdhci_host *host, u8 mask)
2597 + sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
2598 + sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
2599 +
2600 ++ if (of_find_compatible_node(NULL, NULL, "fsl,p2020-esdhc"))
2601 ++ mdelay(5);
2602 ++
2603 + if (mask & SDHCI_RESET_ALL) {
2604 + val = sdhci_readl(host, ESDHC_TBCTL);
2605 + val &= ~ESDHC_TB_EN;
2606 +@@ -880,6 +883,11 @@ static int sdhci_esdhc_probe(struct platform_device *pdev)
2607 + if (esdhc->vendor_ver > VENDOR_V_22)
2608 + host->quirks &= ~SDHCI_QUIRK_NO_BUSY_IRQ;
2609 +
2610 ++ if (of_find_compatible_node(NULL, NULL, "fsl,p2020-esdhc")) {
2611 ++ host->quirks2 |= SDHCI_QUIRK_RESET_AFTER_REQUEST;
2612 ++ host->quirks2 |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
2613 ++ }
2614 ++
2615 + if (of_device_is_compatible(np, "fsl,p5040-esdhc") ||
2616 + of_device_is_compatible(np, "fsl,p5020-esdhc") ||
2617 + of_device_is_compatible(np, "fsl,p4080-esdhc") ||
2618 +diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
2619 +index 3c7813f04962..db6f6a877f63 100644
2620 +--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
2621 ++++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
2622 +@@ -2229,7 +2229,7 @@ static void ena_config_host_info(struct ena_com_dev *ena_dev)
2623 +
2624 + host_info->os_type = ENA_ADMIN_OS_LINUX;
2625 + host_info->kernel_ver = LINUX_VERSION_CODE;
2626 +- strncpy(host_info->kernel_ver_str, utsname()->version,
2627 ++ strlcpy(host_info->kernel_ver_str, utsname()->version,
2628 + sizeof(host_info->kernel_ver_str) - 1);
2629 + host_info->os_dist = 0;
2630 + strncpy(host_info->os_dist_str, utsname()->release,
2631 +diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
2632 +index c2fd323c4078..ea75f275023f 100644
2633 +--- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
2634 ++++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
2635 +@@ -75,8 +75,8 @@ struct l2t_data {
2636 + struct l2t_entry *rover; /* starting point for next allocation */
2637 + atomic_t nfree; /* number of free entries */
2638 + rwlock_t lock;
2639 +- struct l2t_entry l2tab[0];
2640 + struct rcu_head rcu_head; /* to handle rcu cleanup */
2641 ++ struct l2t_entry l2tab[];
2642 + };
2643 +
2644 + typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
2645 +diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
2646 +index 74a42f12064b..0e13989608f1 100644
2647 +--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
2648 ++++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
2649 +@@ -5399,15 +5399,24 @@ static int __init cxgb4_init_module(void)
2650 +
2651 + ret = pci_register_driver(&cxgb4_driver);
2652 + if (ret < 0)
2653 +- debugfs_remove(cxgb4_debugfs_root);
2654 ++ goto err_pci;
2655 +
2656 + #if IS_ENABLED(CONFIG_IPV6)
2657 + if (!inet6addr_registered) {
2658 +- register_inet6addr_notifier(&cxgb4_inet6addr_notifier);
2659 +- inet6addr_registered = true;
2660 ++ ret = register_inet6addr_notifier(&cxgb4_inet6addr_notifier);
2661 ++ if (ret)
2662 ++ pci_unregister_driver(&cxgb4_driver);
2663 ++ else
2664 ++ inet6addr_registered = true;
2665 + }
2666 + #endif
2667 +
2668 ++ if (ret == 0)
2669 ++ return ret;
2670 ++
2671 ++err_pci:
2672 ++ debugfs_remove(cxgb4_debugfs_root);
2673 ++
2674 + return ret;
2675 + }
2676 +
2677 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
2678 +index 5d47a51e74eb..39029a12a233 100644
2679 +--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
2680 ++++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
2681 +@@ -2499,6 +2499,10 @@ void i40e_vlan_stripping_enable(struct i40e_vsi *vsi)
2682 + struct i40e_vsi_context ctxt;
2683 + i40e_status ret;
2684 +
2685 ++ /* Don't modify stripping options if a port VLAN is active */
2686 ++ if (vsi->info.pvid)
2687 ++ return;
2688 ++
2689 + if ((vsi->info.valid_sections &
2690 + cpu_to_le16(I40E_AQ_VSI_PROP_VLAN_VALID)) &&
2691 + ((vsi->info.port_vlan_flags & I40E_AQ_VSI_PVLAN_MODE_MASK) == 0))
2692 +@@ -2529,6 +2533,10 @@ void i40e_vlan_stripping_disable(struct i40e_vsi *vsi)
2693 + struct i40e_vsi_context ctxt;
2694 + i40e_status ret;
2695 +
2696 ++ /* Don't modify stripping options if a port VLAN is active */
2697 ++ if (vsi->info.pvid)
2698 ++ return;
2699 ++
2700 + if ((vsi->info.valid_sections &
2701 + cpu_to_le16(I40E_AQ_VSI_PROP_VLAN_VALID)) &&
2702 + ((vsi->info.port_vlan_flags & I40E_AQ_VSI_PVLAN_EMOD_MASK) ==
2703 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
2704 +index 4a85a24ced1c..bdb752321600 100644
2705 +--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
2706 ++++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
2707 +@@ -2029,8 +2029,10 @@ error_param:
2708 + (u8 *)&stats, sizeof(stats));
2709 + }
2710 +
2711 +-/* If the VF is not trusted restrict the number of MAC/VLAN it can program */
2712 +-#define I40E_VC_MAX_MAC_ADDR_PER_VF 12
2713 ++/* If the VF is not trusted restrict the number of MAC/VLAN it can program
2714 ++ * MAC filters: 16 for multicast, 1 for MAC, 1 for broadcast
2715 ++ */
2716 ++#define I40E_VC_MAX_MAC_ADDR_PER_VF (16 + 1 + 1)
2717 + #define I40E_VC_MAX_VLAN_PER_VF 8
2718 +
2719 + /**
2720 +diff --git a/drivers/net/wireless/atmel/at76c50x-usb.c b/drivers/net/wireless/atmel/at76c50x-usb.c
2721 +index 94bf01f8b2a8..14f0cc36854f 100644
2722 +--- a/drivers/net/wireless/atmel/at76c50x-usb.c
2723 ++++ b/drivers/net/wireless/atmel/at76c50x-usb.c
2724 +@@ -2585,8 +2585,8 @@ static int __init at76_mod_init(void)
2725 + if (result < 0)
2726 + printk(KERN_ERR DRIVER_NAME
2727 + ": usb_register failed (status %d)\n", result);
2728 +-
2729 +- led_trigger_register_simple("at76_usb-tx", &ledtrig_tx);
2730 ++ else
2731 ++ led_trigger_register_simple("at76_usb-tx", &ledtrig_tx);
2732 + return result;
2733 + }
2734 +
2735 +diff --git a/drivers/net/wireless/broadcom/b43/phy_lp.c b/drivers/net/wireless/broadcom/b43/phy_lp.c
2736 +index 6922cbb99a04..5a0699fb4b9a 100644
2737 +--- a/drivers/net/wireless/broadcom/b43/phy_lp.c
2738 ++++ b/drivers/net/wireless/broadcom/b43/phy_lp.c
2739 +@@ -1834,7 +1834,7 @@ static void lpphy_papd_cal(struct b43_wldev *dev, struct lpphy_tx_gains gains,
2740 + static void lpphy_papd_cal_txpwr(struct b43_wldev *dev)
2741 + {
2742 + struct b43_phy_lp *lpphy = dev->phy.lp;
2743 +- struct lpphy_tx_gains gains, oldgains;
2744 ++ struct lpphy_tx_gains oldgains;
2745 + int old_txpctl, old_afe_ovr, old_rf, old_bbmult;
2746 +
2747 + lpphy_read_tx_pctl_mode_from_hardware(dev);
2748 +@@ -1848,9 +1848,9 @@ static void lpphy_papd_cal_txpwr(struct b43_wldev *dev)
2749 + lpphy_set_tx_power_control(dev, B43_LPPHY_TXPCTL_OFF);
2750 +
2751 + if (dev->dev->chip_id == 0x4325 && dev->dev->chip_rev == 0)
2752 +- lpphy_papd_cal(dev, gains, 0, 1, 30);
2753 ++ lpphy_papd_cal(dev, oldgains, 0, 1, 30);
2754 + else
2755 +- lpphy_papd_cal(dev, gains, 0, 1, 65);
2756 ++ lpphy_papd_cal(dev, oldgains, 0, 1, 65);
2757 +
2758 + if (old_afe_ovr)
2759 + lpphy_set_tx_gains(dev, oldgains);
2760 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
2761 +index cd6c5ece9a5d..04fa66ed99a0 100644
2762 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
2763 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
2764 +@@ -3581,6 +3581,8 @@ brcmf_wowl_nd_results(struct brcmf_if *ifp, const struct brcmf_event_msg *e,
2765 + }
2766 +
2767 + netinfo = brcmf_get_netinfo_array(pfn_result);
2768 ++ if (netinfo->SSID_len > IEEE80211_MAX_SSID_LEN)
2769 ++ netinfo->SSID_len = IEEE80211_MAX_SSID_LEN;
2770 + memcpy(cfg->wowl.nd->ssid.ssid, netinfo->SSID, netinfo->SSID_len);
2771 + cfg->wowl.nd->ssid.ssid_len = netinfo->SSID_len;
2772 + cfg->wowl.nd->n_channels = 1;
2773 +@@ -5465,6 +5467,8 @@ static s32 brcmf_get_assoc_ies(struct brcmf_cfg80211_info *cfg,
2774 + conn_info->req_ie =
2775 + kmemdup(cfg->extra_buf, conn_info->req_ie_len,
2776 + GFP_KERNEL);
2777 ++ if (!conn_info->req_ie)
2778 ++ conn_info->req_ie_len = 0;
2779 + } else {
2780 + conn_info->req_ie_len = 0;
2781 + conn_info->req_ie = NULL;
2782 +@@ -5481,6 +5485,8 @@ static s32 brcmf_get_assoc_ies(struct brcmf_cfg80211_info *cfg,
2783 + conn_info->resp_ie =
2784 + kmemdup(cfg->extra_buf, conn_info->resp_ie_len,
2785 + GFP_KERNEL);
2786 ++ if (!conn_info->resp_ie)
2787 ++ conn_info->resp_ie_len = 0;
2788 + } else {
2789 + conn_info->resp_ie_len = 0;
2790 + conn_info->resp_ie = NULL;
2791 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
2792 +index 5cc3a07dda9e..bfc0e37b7f34 100644
2793 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
2794 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
2795 +@@ -344,7 +344,8 @@ void brcmf_rx_frame(struct device *dev, struct sk_buff *skb, bool handle_event)
2796 + } else {
2797 + /* Process special event packets */
2798 + if (handle_event)
2799 +- brcmf_fweh_process_skb(ifp->drvr, skb);
2800 ++ brcmf_fweh_process_skb(ifp->drvr, skb,
2801 ++ BCMILCP_SUBTYPE_VENDOR_LONG);
2802 +
2803 + brcmf_netif_rx(ifp, skb);
2804 + }
2805 +@@ -361,7 +362,7 @@ void brcmf_rx_event(struct device *dev, struct sk_buff *skb)
2806 + if (brcmf_rx_hdrpull(drvr, skb, &ifp))
2807 + return;
2808 +
2809 +- brcmf_fweh_process_skb(ifp->drvr, skb);
2810 ++ brcmf_fweh_process_skb(ifp->drvr, skb, 0);
2811 + brcmu_pkt_buf_free_skb(skb);
2812 + }
2813 +
2814 +@@ -663,17 +664,17 @@ static void brcmf_del_if(struct brcmf_pub *drvr, s32 bsscfgidx,
2815 + bool rtnl_locked)
2816 + {
2817 + struct brcmf_if *ifp;
2818 ++ int ifidx;
2819 +
2820 + ifp = drvr->iflist[bsscfgidx];
2821 +- drvr->iflist[bsscfgidx] = NULL;
2822 + if (!ifp) {
2823 + brcmf_err("Null interface, bsscfgidx=%d\n", bsscfgidx);
2824 + return;
2825 + }
2826 + brcmf_dbg(TRACE, "Enter, bsscfgidx=%d, ifidx=%d\n", bsscfgidx,
2827 + ifp->ifidx);
2828 +- if (drvr->if2bss[ifp->ifidx] == bsscfgidx)
2829 +- drvr->if2bss[ifp->ifidx] = BRCMF_BSSIDX_INVALID;
2830 ++ ifidx = ifp->ifidx;
2831 ++
2832 + if (ifp->ndev) {
2833 + if (bsscfgidx == 0) {
2834 + if (ifp->ndev->netdev_ops == &brcmf_netdev_ops_pri) {
2835 +@@ -701,6 +702,10 @@ static void brcmf_del_if(struct brcmf_pub *drvr, s32 bsscfgidx,
2836 + brcmf_p2p_ifp_removed(ifp, rtnl_locked);
2837 + kfree(ifp);
2838 + }
2839 ++
2840 ++ drvr->iflist[bsscfgidx] = NULL;
2841 ++ if (drvr->if2bss[ifidx] == bsscfgidx)
2842 ++ drvr->if2bss[ifidx] = BRCMF_BSSIDX_INVALID;
2843 + }
2844 +
2845 + void brcmf_remove_interface(struct brcmf_if *ifp, bool rtnl_locked)
2846 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.h
2847 +index 816f80ea925b..ebd66fe0d949 100644
2848 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.h
2849 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.h
2850 +@@ -211,7 +211,7 @@ enum brcmf_fweh_event_code {
2851 + */
2852 + #define BRCM_OUI "\x00\x10\x18"
2853 + #define BCMILCP_BCM_SUBTYPE_EVENT 1
2854 +-
2855 ++#define BCMILCP_SUBTYPE_VENDOR_LONG 32769
2856 +
2857 + /**
2858 + * struct brcm_ethhdr - broadcom specific ether header.
2859 +@@ -334,10 +334,10 @@ void brcmf_fweh_process_event(struct brcmf_pub *drvr,
2860 + void brcmf_fweh_p2pdev_setup(struct brcmf_if *ifp, bool ongoing);
2861 +
2862 + static inline void brcmf_fweh_process_skb(struct brcmf_pub *drvr,
2863 +- struct sk_buff *skb)
2864 ++ struct sk_buff *skb, u16 stype)
2865 + {
2866 + struct brcmf_event *event_packet;
2867 +- u16 usr_stype;
2868 ++ u16 subtype, usr_stype;
2869 +
2870 + /* only process events when protocol matches */
2871 + if (skb->protocol != cpu_to_be16(ETH_P_LINK_CTL))
2872 +@@ -346,8 +346,16 @@ static inline void brcmf_fweh_process_skb(struct brcmf_pub *drvr,
2873 + if ((skb->len + ETH_HLEN) < sizeof(*event_packet))
2874 + return;
2875 +
2876 +- /* check for BRCM oui match */
2877 + event_packet = (struct brcmf_event *)skb_mac_header(skb);
2878 ++
2879 ++ /* check subtype if needed */
2880 ++ if (unlikely(stype)) {
2881 ++ subtype = get_unaligned_be16(&event_packet->hdr.subtype);
2882 ++ if (subtype != stype)
2883 ++ return;
2884 ++ }
2885 ++
2886 ++ /* check for BRCM oui match */
2887 + if (memcmp(BRCM_OUI, &event_packet->hdr.oui[0],
2888 + sizeof(event_packet->hdr.oui)))
2889 + return;
2890 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
2891 +index f59642b2c935..2370060ef980 100644
2892 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
2893 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
2894 +@@ -579,24 +579,6 @@ static bool brcmf_fws_ifidx_match(struct sk_buff *skb, void *arg)
2895 + return ifidx == *(int *)arg;
2896 + }
2897 +
2898 +-static void brcmf_fws_psq_flush(struct brcmf_fws_info *fws, struct pktq *q,
2899 +- int ifidx)
2900 +-{
2901 +- bool (*matchfn)(struct sk_buff *, void *) = NULL;
2902 +- struct sk_buff *skb;
2903 +- int prec;
2904 +-
2905 +- if (ifidx != -1)
2906 +- matchfn = brcmf_fws_ifidx_match;
2907 +- for (prec = 0; prec < q->num_prec; prec++) {
2908 +- skb = brcmu_pktq_pdeq_match(q, prec, matchfn, &ifidx);
2909 +- while (skb) {
2910 +- brcmu_pkt_buf_free_skb(skb);
2911 +- skb = brcmu_pktq_pdeq_match(q, prec, matchfn, &ifidx);
2912 +- }
2913 +- }
2914 +-}
2915 +-
2916 + static void brcmf_fws_hanger_init(struct brcmf_fws_hanger *hanger)
2917 + {
2918 + int i;
2919 +@@ -668,6 +650,28 @@ static inline int brcmf_fws_hanger_poppkt(struct brcmf_fws_hanger *h,
2920 + return 0;
2921 + }
2922 +
2923 ++static void brcmf_fws_psq_flush(struct brcmf_fws_info *fws, struct pktq *q,
2924 ++ int ifidx)
2925 ++{
2926 ++ bool (*matchfn)(struct sk_buff *, void *) = NULL;
2927 ++ struct sk_buff *skb;
2928 ++ int prec;
2929 ++ u32 hslot;
2930 ++
2931 ++ if (ifidx != -1)
2932 ++ matchfn = brcmf_fws_ifidx_match;
2933 ++ for (prec = 0; prec < q->num_prec; prec++) {
2934 ++ skb = brcmu_pktq_pdeq_match(q, prec, matchfn, &ifidx);
2935 ++ while (skb) {
2936 ++ hslot = brcmf_skb_htod_tag_get_field(skb, HSLOT);
2937 ++ brcmf_fws_hanger_poppkt(&fws->hanger, hslot, &skb,
2938 ++ true);
2939 ++ brcmu_pkt_buf_free_skb(skb);
2940 ++ skb = brcmu_pktq_pdeq_match(q, prec, matchfn, &ifidx);
2941 ++ }
2942 ++ }
2943 ++}
2944 ++
2945 + static int brcmf_fws_hanger_mark_suppressed(struct brcmf_fws_hanger *h,
2946 + u32 slot_id)
2947 + {
2948 +@@ -2168,6 +2172,8 @@ void brcmf_fws_del_interface(struct brcmf_if *ifp)
2949 + brcmf_fws_lock(fws);
2950 + ifp->fws_desc = NULL;
2951 + brcmf_dbg(TRACE, "deleting %s\n", entry->name);
2952 ++ brcmf_fws_macdesc_cleanup(fws, &fws->desc.iface[ifp->ifidx],
2953 ++ ifp->ifidx);
2954 + brcmf_fws_macdesc_deinit(entry);
2955 + brcmf_fws_cleanup(fws, ifp->ifidx);
2956 + brcmf_fws_unlock(fws);
2957 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
2958 +index d2c834c3b2fc..65e16e3646ec 100644
2959 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
2960 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
2961 +@@ -1112,7 +1112,7 @@ static void brcmf_msgbuf_process_event(struct brcmf_msgbuf *msgbuf, void *buf)
2962 +
2963 + skb->protocol = eth_type_trans(skb, ifp->ndev);
2964 +
2965 +- brcmf_fweh_process_skb(ifp->drvr, skb);
2966 ++ brcmf_fweh_process_skb(ifp->drvr, skb, 0);
2967 +
2968 + exit:
2969 + brcmu_pkt_buf_free_skb(skb);
2970 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
2971 +index 11ffaa01599e..be855aa32154 100644
2972 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
2973 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
2974 +@@ -160,7 +160,7 @@ struct brcmf_usbdev_info {
2975 +
2976 + struct usb_device *usbdev;
2977 + struct device *dev;
2978 +- struct mutex dev_init_lock;
2979 ++ struct completion dev_init_done;
2980 +
2981 + int ctl_in_pipe, ctl_out_pipe;
2982 + struct urb *ctl_urb; /* URB for control endpoint */
2983 +@@ -684,12 +684,18 @@ static int brcmf_usb_up(struct device *dev)
2984 +
2985 + static void brcmf_cancel_all_urbs(struct brcmf_usbdev_info *devinfo)
2986 + {
2987 ++ int i;
2988 ++
2989 + if (devinfo->ctl_urb)
2990 + usb_kill_urb(devinfo->ctl_urb);
2991 + if (devinfo->bulk_urb)
2992 + usb_kill_urb(devinfo->bulk_urb);
2993 +- brcmf_usb_free_q(&devinfo->tx_postq, true);
2994 +- brcmf_usb_free_q(&devinfo->rx_postq, true);
2995 ++ if (devinfo->tx_reqs)
2996 ++ for (i = 0; i < devinfo->bus_pub.ntxq; i++)
2997 ++ usb_kill_urb(devinfo->tx_reqs[i].urb);
2998 ++ if (devinfo->rx_reqs)
2999 ++ for (i = 0; i < devinfo->bus_pub.nrxq; i++)
3000 ++ usb_kill_urb(devinfo->rx_reqs[i].urb);
3001 + }
3002 +
3003 + static void brcmf_usb_down(struct device *dev)
3004 +@@ -1192,11 +1198,11 @@ static void brcmf_usb_probe_phase2(struct device *dev, int ret,
3005 + if (ret)
3006 + goto error;
3007 +
3008 +- mutex_unlock(&devinfo->dev_init_lock);
3009 ++ complete(&devinfo->dev_init_done);
3010 + return;
3011 + error:
3012 + brcmf_dbg(TRACE, "failed: dev=%s, err=%d\n", dev_name(dev), ret);
3013 +- mutex_unlock(&devinfo->dev_init_lock);
3014 ++ complete(&devinfo->dev_init_done);
3015 + device_release_driver(dev);
3016 + }
3017 +
3018 +@@ -1242,7 +1248,7 @@ static int brcmf_usb_probe_cb(struct brcmf_usbdev_info *devinfo)
3019 + if (ret)
3020 + goto fail;
3021 + /* we are done */
3022 +- mutex_unlock(&devinfo->dev_init_lock);
3023 ++ complete(&devinfo->dev_init_done);
3024 + return 0;
3025 + }
3026 + bus->chip = bus_pub->devid;
3027 +@@ -1303,11 +1309,10 @@ brcmf_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
3028 +
3029 + devinfo->usbdev = usb;
3030 + devinfo->dev = &usb->dev;
3031 +- /* Take an init lock, to protect for disconnect while still loading.
3032 ++ /* Init completion, to protect for disconnect while still loading.
3033 + * Necessary because of the asynchronous firmware load construction
3034 + */
3035 +- mutex_init(&devinfo->dev_init_lock);
3036 +- mutex_lock(&devinfo->dev_init_lock);
3037 ++ init_completion(&devinfo->dev_init_done);
3038 +
3039 + usb_set_intfdata(intf, devinfo);
3040 +
3041 +@@ -1385,7 +1390,7 @@ brcmf_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
3042 + return 0;
3043 +
3044 + fail:
3045 +- mutex_unlock(&devinfo->dev_init_lock);
3046 ++ complete(&devinfo->dev_init_done);
3047 + kfree(devinfo);
3048 + usb_set_intfdata(intf, NULL);
3049 + return ret;
3050 +@@ -1400,7 +1405,7 @@ brcmf_usb_disconnect(struct usb_interface *intf)
3051 + devinfo = (struct brcmf_usbdev_info *)usb_get_intfdata(intf);
3052 +
3053 + if (devinfo) {
3054 +- mutex_lock(&devinfo->dev_init_lock);
3055 ++ wait_for_completion(&devinfo->dev_init_done);
3056 + /* Make sure that devinfo still exists. Firmware probe routines
3057 + * may have released the device and cleared the intfdata.
3058 + */
3059 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c
3060 +index 8eff2753abad..d493021f6031 100644
3061 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c
3062 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c
3063 +@@ -35,9 +35,10 @@ static int brcmf_cfg80211_vndr_cmds_dcmd_handler(struct wiphy *wiphy,
3064 + struct brcmf_if *ifp;
3065 + const struct brcmf_vndr_dcmd_hdr *cmdhdr = data;
3066 + struct sk_buff *reply;
3067 +- int ret, payload, ret_len;
3068 ++ unsigned int payload, ret_len;
3069 + void *dcmd_buf = NULL, *wr_pointer;
3070 + u16 msglen, maxmsglen = PAGE_SIZE - 0x100;
3071 ++ int ret;
3072 +
3073 + if (len < sizeof(*cmdhdr)) {
3074 + brcmf_err("vendor command too short: %d\n", len);
3075 +@@ -65,7 +66,7 @@ static int brcmf_cfg80211_vndr_cmds_dcmd_handler(struct wiphy *wiphy,
3076 + brcmf_err("oversize return buffer %d\n", ret_len);
3077 + ret_len = BRCMF_DCMD_MAXLEN;
3078 + }
3079 +- payload = max(ret_len, len) + 1;
3080 ++ payload = max_t(unsigned int, ret_len, len) + 1;
3081 + dcmd_buf = vzalloc(payload);
3082 + if (NULL == dcmd_buf)
3083 + return -ENOMEM;
3084 +diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
3085 +index a40ad4675e19..953e0254a94c 100644
3086 +--- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
3087 ++++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
3088 +@@ -1252,10 +1252,15 @@ static void iwl_pcie_rx_handle_rb(struct iwl_trans *trans,
3089 + static void iwl_pcie_rx_handle(struct iwl_trans *trans, int queue)
3090 + {
3091 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
3092 +- struct iwl_rxq *rxq = &trans_pcie->rxq[queue];
3093 ++ struct iwl_rxq *rxq;
3094 + u32 r, i, count = 0;
3095 + bool emergency = false;
3096 +
3097 ++ if (WARN_ON_ONCE(!trans_pcie->rxq || !trans_pcie->rxq[queue].bd))
3098 ++ return;
3099 ++
3100 ++ rxq = &trans_pcie->rxq[queue];
3101 ++
3102 + restart:
3103 + spin_lock(&rxq->lock);
3104 + /* uCode's read index (stored in shared DRAM) indicates the last Rx
3105 +diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
3106 +index 68aa0c7a8139..dde47c548818 100644
3107 +--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
3108 ++++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
3109 +@@ -4024,16 +4024,20 @@ static int mwifiex_tm_cmd(struct wiphy *wiphy, struct wireless_dev *wdev,
3110 +
3111 + if (mwifiex_send_cmd(priv, 0, 0, 0, hostcmd, true)) {
3112 + dev_err(priv->adapter->dev, "Failed to process hostcmd\n");
3113 ++ kfree(hostcmd);
3114 + return -EFAULT;
3115 + }
3116 +
3117 + /* process hostcmd response*/
3118 + skb = cfg80211_testmode_alloc_reply_skb(wiphy, hostcmd->len);
3119 +- if (!skb)
3120 ++ if (!skb) {
3121 ++ kfree(hostcmd);
3122 + return -ENOMEM;
3123 ++ }
3124 + err = nla_put(skb, MWIFIEX_TM_ATTR_DATA,
3125 + hostcmd->len, hostcmd->cmd);
3126 + if (err) {
3127 ++ kfree(hostcmd);
3128 + kfree_skb(skb);
3129 + return -EMSGSIZE;
3130 + }
3131 +diff --git a/drivers/net/wireless/marvell/mwifiex/cfp.c b/drivers/net/wireless/marvell/mwifiex/cfp.c
3132 +index bfe84e55df77..f1522fb1c1e8 100644
3133 +--- a/drivers/net/wireless/marvell/mwifiex/cfp.c
3134 ++++ b/drivers/net/wireless/marvell/mwifiex/cfp.c
3135 +@@ -531,5 +531,8 @@ u8 mwifiex_adjust_data_rate(struct mwifiex_private *priv,
3136 + rate_index = (rx_rate > MWIFIEX_RATE_INDEX_OFDM0) ?
3137 + rx_rate - 1 : rx_rate;
3138 +
3139 ++ if (rate_index >= MWIFIEX_MAX_AC_RX_RATES)
3140 ++ rate_index = MWIFIEX_MAX_AC_RX_RATES - 1;
3141 ++
3142 + return rate_index;
3143 + }
3144 +diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c b/drivers/net/wireless/realtek/rtlwifi/base.c
3145 +index ec82c1c3f12e..4a3c713ad324 100644
3146 +--- a/drivers/net/wireless/realtek/rtlwifi/base.c
3147 ++++ b/drivers/net/wireless/realtek/rtlwifi/base.c
3148 +@@ -468,6 +468,11 @@ static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
3149 + /* <2> work queue */
3150 + rtlpriv->works.hw = hw;
3151 + rtlpriv->works.rtl_wq = alloc_workqueue("%s", 0, 0, rtlpriv->cfg->name);
3152 ++ if (unlikely(!rtlpriv->works.rtl_wq)) {
3153 ++ pr_err("Failed to allocate work queue\n");
3154 ++ return;
3155 ++ }
3156 ++
3157 + INIT_DELAYED_WORK(&rtlpriv->works.watchdog_wq,
3158 + (void *)rtl_watchdog_wq_callback);
3159 + INIT_DELAYED_WORK(&rtlpriv->works.ips_nic_off_wq,
3160 +diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/fw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/fw.c
3161 +index a2eca669873b..726d3d5fa2ef 100644
3162 +--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/fw.c
3163 ++++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/fw.c
3164 +@@ -620,6 +620,8 @@ void rtl88e_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)
3165 + u1rsvdpageloc, 3);
3166 +
3167 + skb = dev_alloc_skb(totalpacketlen);
3168 ++ if (!skb)
3169 ++ return;
3170 + skb_put_data(skb, &reserved_page_packet, totalpacketlen);
3171 +
3172 + rtstatus = rtl_cmd_send_packet(hw, skb);
3173 +diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192c/fw_common.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192c/fw_common.c
3174 +index 015476e3f7e5..b7c1d7cc4f45 100644
3175 +--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192c/fw_common.c
3176 ++++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192c/fw_common.c
3177 +@@ -647,6 +647,8 @@ void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw,
3178 +
3179 +
3180 + skb = dev_alloc_skb(totalpacketlen);
3181 ++ if (!skb)
3182 ++ return;
3183 + skb_put_data(skb, &reserved_page_packet, totalpacketlen);
3184 +
3185 + if (cmd_send_packet)
3186 +diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
3187 +index f9563ae301ad..45808ab025d1 100644
3188 +--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
3189 ++++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
3190 +@@ -766,6 +766,8 @@ void rtl92ee_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)
3191 + u1rsvdpageloc, 3);
3192 +
3193 + skb = dev_alloc_skb(totalpacketlen);
3194 ++ if (!skb)
3195 ++ return;
3196 + skb_put_data(skb, &reserved_page_packet, totalpacketlen);
3197 +
3198 + rtstatus = rtl_cmd_send_packet(hw, skb);
3199 +diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/fw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/fw.c
3200 +index bf9859f74b6f..52f108744e96 100644
3201 +--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/fw.c
3202 ++++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/fw.c
3203 +@@ -470,6 +470,8 @@ void rtl8723e_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)
3204 + u1rsvdpageloc, 3);
3205 +
3206 + skb = dev_alloc_skb(totalpacketlen);
3207 ++ if (!skb)
3208 ++ return;
3209 + skb_put_data(skb, &reserved_page_packet, totalpacketlen);
3210 +
3211 + rtstatus = rtl_cmd_send_packet(hw, skb);
3212 +diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/fw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/fw.c
3213 +index 4b963fd27d64..b444b27263c3 100644
3214 +--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/fw.c
3215 ++++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/fw.c
3216 +@@ -584,6 +584,8 @@ void rtl8723be_set_fw_rsvdpagepkt(struct ieee80211_hw *hw,
3217 + u1rsvdpageloc, sizeof(u1rsvdpageloc));
3218 +
3219 + skb = dev_alloc_skb(totalpacketlen);
3220 ++ if (!skb)
3221 ++ return;
3222 + skb_put_data(skb, &reserved_page_packet, totalpacketlen);
3223 +
3224 + rtstatus = rtl_cmd_send_packet(hw, skb);
3225 +diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c
3226 +index f2b2c549e5b2..53a7ef29fce6 100644
3227 +--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c
3228 ++++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c
3229 +@@ -1645,6 +1645,8 @@ out:
3230 + &reserved_page_packet_8812[0], totalpacketlen);
3231 +
3232 + skb = dev_alloc_skb(totalpacketlen);
3233 ++ if (!skb)
3234 ++ return;
3235 + skb_put_data(skb, &reserved_page_packet_8812, totalpacketlen);
3236 +
3237 + rtstatus = rtl_cmd_send_packet(hw, skb);
3238 +@@ -1781,6 +1783,8 @@ out:
3239 + &reserved_page_packet_8821[0], totalpacketlen);
3240 +
3241 + skb = dev_alloc_skb(totalpacketlen);
3242 ++ if (!skb)
3243 ++ return;
3244 + skb_put_data(skb, &reserved_page_packet_8821, totalpacketlen);
3245 +
3246 + rtstatus = rtl_cmd_send_packet(hw, skb);
3247 +diff --git a/drivers/net/wireless/st/cw1200/main.c b/drivers/net/wireless/st/cw1200/main.c
3248 +index dc478cedbde0..84624c812a15 100644
3249 +--- a/drivers/net/wireless/st/cw1200/main.c
3250 ++++ b/drivers/net/wireless/st/cw1200/main.c
3251 +@@ -345,6 +345,11 @@ static struct ieee80211_hw *cw1200_init_common(const u8 *macaddr,
3252 + mutex_init(&priv->wsm_cmd_mux);
3253 + mutex_init(&priv->conf_mutex);
3254 + priv->workqueue = create_singlethread_workqueue("cw1200_wq");
3255 ++ if (!priv->workqueue) {
3256 ++ ieee80211_free_hw(hw);
3257 ++ return NULL;
3258 ++ }
3259 ++
3260 + sema_init(&priv->scan.lock, 1);
3261 + INIT_WORK(&priv->scan.work, cw1200_scan_work);
3262 + INIT_DELAYED_WORK(&priv->scan.probe_work, cw1200_probe_work);
3263 +diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c
3264 +index 184149a49b02..6a16017cc0d9 100644
3265 +--- a/drivers/nvdimm/label.c
3266 ++++ b/drivers/nvdimm/label.c
3267 +@@ -614,6 +614,17 @@ static const guid_t *to_abstraction_guid(enum nvdimm_claim_class claim_class,
3268 + return &guid_null;
3269 + }
3270 +
3271 ++static void reap_victim(struct nd_mapping *nd_mapping,
3272 ++ struct nd_label_ent *victim)
3273 ++{
3274 ++ struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
3275 ++ u32 slot = to_slot(ndd, victim->label);
3276 ++
3277 ++ dev_dbg(ndd->dev, "free: %d\n", slot);
3278 ++ nd_label_free_slot(ndd, slot);
3279 ++ victim->label = NULL;
3280 ++}
3281 ++
3282 + static int __pmem_label_update(struct nd_region *nd_region,
3283 + struct nd_mapping *nd_mapping, struct nd_namespace_pmem *nspm,
3284 + int pos, unsigned long flags)
3285 +@@ -621,9 +632,9 @@ static int __pmem_label_update(struct nd_region *nd_region,
3286 + struct nd_namespace_common *ndns = &nspm->nsio.common;
3287 + struct nd_interleave_set *nd_set = nd_region->nd_set;
3288 + struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
3289 +- struct nd_label_ent *label_ent, *victim = NULL;
3290 + struct nd_namespace_label *nd_label;
3291 + struct nd_namespace_index *nsindex;
3292 ++ struct nd_label_ent *label_ent;
3293 + struct nd_label_id label_id;
3294 + struct resource *res;
3295 + unsigned long *free;
3296 +@@ -692,18 +703,10 @@ static int __pmem_label_update(struct nd_region *nd_region,
3297 + list_for_each_entry(label_ent, &nd_mapping->labels, list) {
3298 + if (!label_ent->label)
3299 + continue;
3300 +- if (memcmp(nspm->uuid, label_ent->label->uuid,
3301 +- NSLABEL_UUID_LEN) != 0)
3302 +- continue;
3303 +- victim = label_ent;
3304 +- list_move_tail(&victim->list, &nd_mapping->labels);
3305 +- break;
3306 +- }
3307 +- if (victim) {
3308 +- dev_dbg(ndd->dev, "%s: free: %d\n", __func__, slot);
3309 +- slot = to_slot(ndd, victim->label);
3310 +- nd_label_free_slot(ndd, slot);
3311 +- victim->label = NULL;
3312 ++ if (test_and_clear_bit(ND_LABEL_REAP, &label_ent->flags)
3313 ++ || memcmp(nspm->uuid, label_ent->label->uuid,
3314 ++ NSLABEL_UUID_LEN) == 0)
3315 ++ reap_victim(nd_mapping, label_ent);
3316 + }
3317 +
3318 + /* update index */
3319 +diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
3320 +index e3f228af59d1..ace9958f2905 100644
3321 +--- a/drivers/nvdimm/namespace_devs.c
3322 ++++ b/drivers/nvdimm/namespace_devs.c
3323 +@@ -1229,12 +1229,27 @@ static int namespace_update_uuid(struct nd_region *nd_region,
3324 + for (i = 0; i < nd_region->ndr_mappings; i++) {
3325 + struct nd_mapping *nd_mapping = &nd_region->mapping[i];
3326 + struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
3327 ++ struct nd_label_ent *label_ent;
3328 + struct resource *res;
3329 +
3330 + for_each_dpa_resource(ndd, res)
3331 + if (strcmp(res->name, old_label_id.id) == 0)
3332 + sprintf((void *) res->name, "%s",
3333 + new_label_id.id);
3334 ++
3335 ++ mutex_lock(&nd_mapping->lock);
3336 ++ list_for_each_entry(label_ent, &nd_mapping->labels, list) {
3337 ++ struct nd_namespace_label *nd_label = label_ent->label;
3338 ++ struct nd_label_id label_id;
3339 ++
3340 ++ if (!nd_label)
3341 ++ continue;
3342 ++ nd_label_gen_id(&label_id, nd_label->uuid,
3343 ++ __le32_to_cpu(nd_label->flags));
3344 ++ if (strcmp(old_label_id.id, label_id.id) == 0)
3345 ++ set_bit(ND_LABEL_REAP, &label_ent->flags);
3346 ++ }
3347 ++ mutex_unlock(&nd_mapping->lock);
3348 + }
3349 + kfree(*old_uuid);
3350 + out:
3351 +diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h
3352 +index 156be00e1f76..e3f060f0b83e 100644
3353 +--- a/drivers/nvdimm/nd.h
3354 ++++ b/drivers/nvdimm/nd.h
3355 +@@ -120,8 +120,12 @@ struct nd_percpu_lane {
3356 + spinlock_t lock;
3357 + };
3358 +
3359 ++enum nd_label_flags {
3360 ++ ND_LABEL_REAP,
3361 ++};
3362 + struct nd_label_ent {
3363 + struct list_head list;
3364 ++ unsigned long flags;
3365 + struct nd_namespace_label *label;
3366 + };
3367 +
3368 +diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
3369 +index 39dfd7affa31..80f8bbf83742 100644
3370 +--- a/drivers/nvdimm/pmem.c
3371 ++++ b/drivers/nvdimm/pmem.c
3372 +@@ -256,10 +256,16 @@ static long pmem_dax_direct_access(struct dax_device *dax_dev,
3373 + return __pmem_direct_access(pmem, pgoff, nr_pages, kaddr, pfn);
3374 + }
3375 +
3376 ++/*
3377 ++ * Use the 'no check' versions of copy_from_iter_flushcache() and
3378 ++ * copy_to_iter_mcsafe() to bypass HARDENED_USERCOPY overhead. Bounds
3379 ++ * checking, both file offset and device offset, is handled by
3380 ++ * dax_iomap_actor()
3381 ++ */
3382 + static size_t pmem_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff,
3383 + void *addr, size_t bytes, struct iov_iter *i)
3384 + {
3385 +- return copy_from_iter_flushcache(addr, bytes, i);
3386 ++ return _copy_from_iter_flushcache(addr, bytes, i);
3387 + }
3388 +
3389 + static const struct dax_operations pmem_dax_ops = {
3390 +diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c
3391 +index 4d34dfb64998..46d60a3bf260 100644
3392 +--- a/drivers/phy/allwinner/phy-sun4i-usb.c
3393 ++++ b/drivers/phy/allwinner/phy-sun4i-usb.c
3394 +@@ -549,6 +549,7 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work)
3395 + struct sun4i_usb_phy_data *data =
3396 + container_of(work, struct sun4i_usb_phy_data, detect.work);
3397 + struct phy *phy0 = data->phys[0].phy;
3398 ++ struct sun4i_usb_phy *phy = phy_get_drvdata(phy0);
3399 + bool force_session_end, id_notify = false, vbus_notify = false;
3400 + int id_det, vbus_det;
3401 +
3402 +@@ -605,6 +606,9 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work)
3403 + mutex_unlock(&phy0->mutex);
3404 + }
3405 +
3406 ++ /* Enable PHY0 passby for host mode only. */
3407 ++ sun4i_usb_phy_passby(phy, !id_det);
3408 ++
3409 + /* Re-route PHY0 if necessary */
3410 + if (data->cfg->phy0_dual_route)
3411 + sun4i_usb_phy0_reroute(data, id_det);
3412 +diff --git a/drivers/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c
3413 +index 55375b1b3cc8..b2b7e238bda9 100644
3414 +--- a/drivers/pinctrl/pinctrl-pistachio.c
3415 ++++ b/drivers/pinctrl/pinctrl-pistachio.c
3416 +@@ -1368,6 +1368,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
3417 + if (!of_find_property(child, "gpio-controller", NULL)) {
3418 + dev_err(pctl->dev,
3419 + "No gpio-controller property for bank %u\n", i);
3420 ++ of_node_put(child);
3421 + ret = -ENODEV;
3422 + goto err;
3423 + }
3424 +@@ -1375,6 +1376,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
3425 + irq = irq_of_parse_and_map(child, 0);
3426 + if (irq < 0) {
3427 + dev_err(pctl->dev, "No IRQ for bank %u: %d\n", i, irq);
3428 ++ of_node_put(child);
3429 + ret = irq;
3430 + goto err;
3431 + }
3432 +diff --git a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
3433 +index afeb4876ffb2..07eb4f071fa8 100644
3434 +--- a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
3435 ++++ b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
3436 +@@ -76,6 +76,7 @@ s5pv210_retention_init(struct samsung_pinctrl_drv_data *drvdata,
3437 + }
3438 +
3439 + clk_base = of_iomap(np, 0);
3440 ++ of_node_put(np);
3441 + if (!clk_base) {
3442 + pr_err("%s: failed to map clock registers\n", __func__);
3443 + return ERR_PTR(-EINVAL);
3444 +diff --git a/drivers/pinctrl/zte/pinctrl-zx.c b/drivers/pinctrl/zte/pinctrl-zx.c
3445 +index ded366bb6564..91955e770236 100644
3446 +--- a/drivers/pinctrl/zte/pinctrl-zx.c
3447 ++++ b/drivers/pinctrl/zte/pinctrl-zx.c
3448 +@@ -411,6 +411,7 @@ int zx_pinctrl_init(struct platform_device *pdev,
3449 + }
3450 +
3451 + zpctl->aux_base = of_iomap(np, 0);
3452 ++ of_node_put(np);
3453 + if (!zpctl->aux_base)
3454 + return -ENOMEM;
3455 +
3456 +diff --git a/drivers/rtc/rtc-88pm860x.c b/drivers/rtc/rtc-88pm860x.c
3457 +index 19e53b3b8e00..166faae3a59c 100644
3458 +--- a/drivers/rtc/rtc-88pm860x.c
3459 ++++ b/drivers/rtc/rtc-88pm860x.c
3460 +@@ -414,7 +414,7 @@ static int pm860x_rtc_remove(struct platform_device *pdev)
3461 + struct pm860x_rtc_info *info = platform_get_drvdata(pdev);
3462 +
3463 + #ifdef VRTC_CALIBRATION
3464 +- flush_scheduled_work();
3465 ++ cancel_delayed_work_sync(&info->calib_work);
3466 + /* disable measurement */
3467 + pm860x_set_bits(info->i2c, PM8607_MEAS_EN2, MEAS2_VRTC, 0);
3468 + #endif /* VRTC_CALIBRATION */
3469 +diff --git a/drivers/rtc/rtc-xgene.c b/drivers/rtc/rtc-xgene.c
3470 +index 65b432a096fe..f68f84205b48 100644
3471 +--- a/drivers/rtc/rtc-xgene.c
3472 ++++ b/drivers/rtc/rtc-xgene.c
3473 +@@ -163,6 +163,10 @@ static int xgene_rtc_probe(struct platform_device *pdev)
3474 + if (IS_ERR(pdata->csr_base))
3475 + return PTR_ERR(pdata->csr_base);
3476 +
3477 ++ pdata->rtc = devm_rtc_allocate_device(&pdev->dev);
3478 ++ if (IS_ERR(pdata->rtc))
3479 ++ return PTR_ERR(pdata->rtc);
3480 ++
3481 + irq = platform_get_irq(pdev, 0);
3482 + if (irq < 0) {
3483 + dev_err(&pdev->dev, "No IRQ resource\n");
3484 +@@ -187,15 +191,15 @@ static int xgene_rtc_probe(struct platform_device *pdev)
3485 +
3486 + device_init_wakeup(&pdev->dev, 1);
3487 +
3488 +- pdata->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
3489 +- &xgene_rtc_ops, THIS_MODULE);
3490 +- if (IS_ERR(pdata->rtc)) {
3491 +- clk_disable_unprepare(pdata->clk);
3492 +- return PTR_ERR(pdata->rtc);
3493 +- }
3494 +-
3495 + /* HW does not support update faster than 1 seconds */
3496 + pdata->rtc->uie_unsupported = 1;
3497 ++ pdata->rtc->ops = &xgene_rtc_ops;
3498 ++
3499 ++ ret = rtc_register_device(pdata->rtc);
3500 ++ if (ret) {
3501 ++ clk_disable_unprepare(pdata->clk);
3502 ++ return ret;
3503 ++ }
3504 +
3505 + return 0;
3506 + }
3507 +diff --git a/drivers/s390/cio/cio.h b/drivers/s390/cio/cio.h
3508 +index 94cd813bdcfe..d23d43cf9cbc 100644
3509 +--- a/drivers/s390/cio/cio.h
3510 ++++ b/drivers/s390/cio/cio.h
3511 +@@ -115,7 +115,7 @@ struct subchannel {
3512 + struct schib_config config;
3513 + } __attribute__ ((aligned(8)));
3514 +
3515 +-DECLARE_PER_CPU(struct irb, cio_irb);
3516 ++DECLARE_PER_CPU_ALIGNED(struct irb, cio_irb);
3517 +
3518 + #define to_subchannel(n) container_of(n, struct subchannel, dev)
3519 +
3520 +diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_drv.c
3521 +index d22759eb6640..6cd41086f23e 100644
3522 +--- a/drivers/s390/cio/vfio_ccw_drv.c
3523 ++++ b/drivers/s390/cio/vfio_ccw_drv.c
3524 +@@ -38,26 +38,30 @@ int vfio_ccw_sch_quiesce(struct subchannel *sch)
3525 + if (ret != -EBUSY)
3526 + goto out_unlock;
3527 +
3528 ++ iretry = 255;
3529 + do {
3530 +- iretry = 255;
3531 +
3532 + ret = cio_cancel_halt_clear(sch, &iretry);
3533 +- while (ret == -EBUSY) {
3534 +- /*
3535 +- * Flush all I/O and wait for
3536 +- * cancel/halt/clear completion.
3537 +- */
3538 +- private->completion = &completion;
3539 +- spin_unlock_irq(sch->lock);
3540 +
3541 +- wait_for_completion_timeout(&completion, 3*HZ);
3542 ++ if (ret == -EIO) {
3543 ++ pr_err("vfio_ccw: could not quiesce subchannel 0.%x.%04x!\n",
3544 ++ sch->schid.ssid, sch->schid.sch_no);
3545 ++ break;
3546 ++ }
3547 ++
3548 ++ /*
3549 ++ * Flush all I/O and wait for
3550 ++ * cancel/halt/clear completion.
3551 ++ */
3552 ++ private->completion = &completion;
3553 ++ spin_unlock_irq(sch->lock);
3554 +
3555 +- spin_lock_irq(sch->lock);
3556 +- private->completion = NULL;
3557 +- flush_workqueue(vfio_ccw_work_q);
3558 +- ret = cio_cancel_halt_clear(sch, &iretry);
3559 +- };
3560 ++ if (ret == -EBUSY)
3561 ++ wait_for_completion_timeout(&completion, 3*HZ);
3562 +
3563 ++ private->completion = NULL;
3564 ++ flush_workqueue(vfio_ccw_work_q);
3565 ++ spin_lock_irq(sch->lock);
3566 + ret = cio_disable_subchannel(sch);
3567 + } while (ret == -EBUSY);
3568 + out_unlock:
3569 +diff --git a/drivers/s390/cio/vfio_ccw_ops.c b/drivers/s390/cio/vfio_ccw_ops.c
3570 +index 41eeb57d68a3..560013c8d2a4 100644
3571 +--- a/drivers/s390/cio/vfio_ccw_ops.c
3572 ++++ b/drivers/s390/cio/vfio_ccw_ops.c
3573 +@@ -130,11 +130,12 @@ static int vfio_ccw_mdev_remove(struct mdev_device *mdev)
3574 +
3575 + if ((private->state != VFIO_CCW_STATE_NOT_OPER) &&
3576 + (private->state != VFIO_CCW_STATE_STANDBY)) {
3577 +- if (!vfio_ccw_mdev_reset(mdev))
3578 ++ if (!vfio_ccw_sch_quiesce(private->sch))
3579 + private->state = VFIO_CCW_STATE_STANDBY;
3580 + /* The state will be NOT_OPER on error. */
3581 + }
3582 +
3583 ++ cp_free(&private->cp);
3584 + private->mdev = NULL;
3585 + atomic_inc(&private->avail);
3586 +
3587 +@@ -158,6 +159,14 @@ static void vfio_ccw_mdev_release(struct mdev_device *mdev)
3588 + struct vfio_ccw_private *private =
3589 + dev_get_drvdata(mdev_parent_dev(mdev));
3590 +
3591 ++ if ((private->state != VFIO_CCW_STATE_NOT_OPER) &&
3592 ++ (private->state != VFIO_CCW_STATE_STANDBY)) {
3593 ++ if (!vfio_ccw_mdev_reset(mdev))
3594 ++ private->state = VFIO_CCW_STATE_STANDBY;
3595 ++ /* The state will be NOT_OPER on error. */
3596 ++ }
3597 ++
3598 ++ cp_free(&private->cp);
3599 + vfio_unregister_notifier(mdev_dev(mdev), VFIO_IOMMU_NOTIFY,
3600 + &private->nb);
3601 + }
3602 +diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c
3603 +index a9a56aa9c26b..3743828106db 100644
3604 +--- a/drivers/s390/crypto/zcrypt_api.c
3605 ++++ b/drivers/s390/crypto/zcrypt_api.c
3606 +@@ -237,6 +237,7 @@ static long zcrypt_rsa_modexpo(struct ica_rsa_modexpo *mex)
3607 + trace_s390_zcrypt_req(mex, TP_ICARSAMODEXPO);
3608 +
3609 + if (mex->outputdatalength < mex->inputdatalength) {
3610 ++ func_code = 0;
3611 + rc = -EINVAL;
3612 + goto out;
3613 + }
3614 +@@ -311,6 +312,7 @@ static long zcrypt_rsa_crt(struct ica_rsa_modexpo_crt *crt)
3615 + trace_s390_zcrypt_req(crt, TP_ICARSACRT);
3616 +
3617 + if (crt->outputdatalength < crt->inputdatalength) {
3618 ++ func_code = 0;
3619 + rc = -EINVAL;
3620 + goto out;
3621 + }
3622 +@@ -492,6 +494,7 @@ static long zcrypt_send_ep11_cprb(struct ep11_urb *xcrb)
3623 +
3624 + targets = kcalloc(target_num, sizeof(*targets), GFP_KERNEL);
3625 + if (!targets) {
3626 ++ func_code = 0;
3627 + rc = -ENOMEM;
3628 + goto out;
3629 + }
3630 +@@ -499,6 +502,7 @@ static long zcrypt_send_ep11_cprb(struct ep11_urb *xcrb)
3631 + uptr = (struct ep11_target_dev __force __user *) xcrb->targets;
3632 + if (copy_from_user(targets, uptr,
3633 + target_num * sizeof(*targets))) {
3634 ++ func_code = 0;
3635 + rc = -EFAULT;
3636 + goto out;
3637 + }
3638 +diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
3639 +index 1c0d2784574a..ffea620a147d 100644
3640 +--- a/drivers/scsi/libsas/sas_expander.c
3641 ++++ b/drivers/scsi/libsas/sas_expander.c
3642 +@@ -2038,6 +2038,11 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id, bool last)
3643 + if ((SAS_ADDR(sas_addr) == 0) || (res == -ECOMM)) {
3644 + phy->phy_state = PHY_EMPTY;
3645 + sas_unregister_devs_sas_addr(dev, phy_id, last);
3646 ++ /*
3647 ++ * Even though the PHY is empty, for convenience we discover
3648 ++ * the PHY to update the PHY info, like negotiated linkrate.
3649 ++ */
3650 ++ sas_ex_phy_discover(dev, phy_id);
3651 + return res;
3652 + } else if (SAS_ADDR(sas_addr) == SAS_ADDR(phy->attached_sas_addr) &&
3653 + dev_type_flutter(type, phy->attached_dev_type)) {
3654 +diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
3655 +index 126723a5bc6f..601a4ee60de8 100644
3656 +--- a/drivers/scsi/lpfc/lpfc_ct.c
3657 ++++ b/drivers/scsi/lpfc/lpfc_ct.c
3658 +@@ -1734,6 +1734,9 @@ lpfc_fdmi_hba_attr_manufacturer(struct lpfc_vport *vport,
3659 + ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
3660 + memset(ae, 0, 256);
3661 +
3662 ++ /* This string MUST be consistent with other FC platforms
3663 ++ * supported by Broadcom.
3664 ++ */
3665 + strncpy(ae->un.AttrString,
3666 + "Emulex Corporation",
3667 + sizeof(ae->un.AttrString));
3668 +@@ -2089,10 +2092,11 @@ lpfc_fdmi_port_attr_fc4type(struct lpfc_vport *vport,
3669 + ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
3670 + memset(ae, 0, 32);
3671 +
3672 +- ae->un.AttrTypes[3] = 0x02; /* Type 1 - ELS */
3673 +- ae->un.AttrTypes[2] = 0x01; /* Type 8 - FCP */
3674 +- ae->un.AttrTypes[6] = 0x01; /* Type 40 - NVME */
3675 +- ae->un.AttrTypes[7] = 0x01; /* Type 32 - CT */
3676 ++ ae->un.AttrTypes[3] = 0x02; /* Type 0x1 - ELS */
3677 ++ ae->un.AttrTypes[2] = 0x01; /* Type 0x8 - FCP */
3678 ++ if (vport->nvmei_support || vport->phba->nvmet_support)
3679 ++ ae->un.AttrTypes[6] = 0x01; /* Type 0x28 - NVME */
3680 ++ ae->un.AttrTypes[7] = 0x01; /* Type 0x20 - CT */
3681 + size = FOURBYTES + 32;
3682 + ad->AttrLen = cpu_to_be16(size);
3683 + ad->AttrType = cpu_to_be16(RPRT_SUPPORTED_FC4_TYPES);
3684 +@@ -2392,9 +2396,11 @@ lpfc_fdmi_port_attr_active_fc4type(struct lpfc_vport *vport,
3685 + ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
3686 + memset(ae, 0, 32);
3687 +
3688 +- ae->un.AttrTypes[3] = 0x02; /* Type 1 - ELS */
3689 +- ae->un.AttrTypes[2] = 0x01; /* Type 8 - FCP */
3690 +- ae->un.AttrTypes[7] = 0x01; /* Type 32 - CT */
3691 ++ ae->un.AttrTypes[3] = 0x02; /* Type 0x1 - ELS */
3692 ++ ae->un.AttrTypes[2] = 0x01; /* Type 0x8 - FCP */
3693 ++ if (vport->phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)
3694 ++ ae->un.AttrTypes[6] = 0x1; /* Type 0x28 - NVME */
3695 ++ ae->un.AttrTypes[7] = 0x01; /* Type 0x20 - CT */
3696 + size = FOURBYTES + 32;
3697 + ad->AttrLen = cpu_to_be16(size);
3698 + ad->AttrType = cpu_to_be16(RPRT_ACTIVE_FC4_TYPES);
3699 +diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
3700 +index 4962d665b4d2..b970933a218d 100644
3701 +--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
3702 ++++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
3703 +@@ -924,7 +924,11 @@ lpfc_linkdown(struct lpfc_hba *phba)
3704 + }
3705 + }
3706 + lpfc_destroy_vport_work_array(phba, vports);
3707 +- /* Clean up any firmware default rpi's */
3708 ++
3709 ++ /* Clean up any SLI3 firmware default rpi's */
3710 ++ if (phba->sli_rev > LPFC_SLI_REV3)
3711 ++ goto skip_unreg_did;
3712 ++
3713 + mb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
3714 + if (mb) {
3715 + lpfc_unreg_did(phba, 0xffff, LPFC_UNREG_ALL_DFLT_RPIS, mb);
3716 +@@ -936,6 +940,7 @@ lpfc_linkdown(struct lpfc_hba *phba)
3717 + }
3718 + }
3719 +
3720 ++ skip_unreg_did:
3721 + /* Setup myDID for link up if we are in pt2pt mode */
3722 + if (phba->pport->fc_flag & FC_PT2PT) {
3723 + mb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
3724 +@@ -4853,6 +4858,10 @@ lpfc_unreg_default_rpis(struct lpfc_vport *vport)
3725 + LPFC_MBOXQ_t *mbox;
3726 + int rc;
3727 +
3728 ++ /* Unreg DID is an SLI3 operation. */
3729 ++ if (phba->sli_rev > LPFC_SLI_REV3)
3730 ++ return;
3731 ++
3732 + mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
3733 + if (mbox) {
3734 + lpfc_unreg_did(phba, vport->vpi, LPFC_UNREG_ALL_DFLT_RPIS,
3735 +diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c
3736 +index ded386036c27..f3e9df8dcd8f 100644
3737 +--- a/drivers/scsi/qedf/qedf_io.c
3738 ++++ b/drivers/scsi/qedf/qedf_io.c
3739 +@@ -883,6 +883,7 @@ int qedf_post_io_req(struct qedf_rport *fcport, struct qedf_ioreq *io_req)
3740 + if (!test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags)) {
3741 + QEDF_ERR(&(qedf->dbg_ctx), "Session not offloaded yet.\n");
3742 + kref_put(&io_req->refcount, qedf_release_cmd);
3743 ++ return -EINVAL;
3744 + }
3745 +
3746 + /* Obtain free SQE */
3747 +diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c
3748 +index 45f044f35cea..0b7267e68336 100644
3749 +--- a/drivers/scsi/qedi/qedi_iscsi.c
3750 ++++ b/drivers/scsi/qedi/qedi_iscsi.c
3751 +@@ -1008,6 +1008,9 @@ static void qedi_ep_disconnect(struct iscsi_endpoint *ep)
3752 + qedi_ep = ep->dd_data;
3753 + qedi = qedi_ep->qedi;
3754 +
3755 ++ if (qedi_ep->state == EP_STATE_OFLDCONN_START)
3756 ++ goto ep_exit_recover;
3757 ++
3758 + flush_work(&qedi_ep->offload_work);
3759 +
3760 + if (qedi_ep->conn) {
3761 +diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
3762 +index e073eb16f8a4..df94ef816826 100644
3763 +--- a/drivers/scsi/qla2xxx/qla_isr.c
3764 ++++ b/drivers/scsi/qla2xxx/qla_isr.c
3765 +@@ -3395,7 +3395,7 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
3766 + ql_log(ql_log_fatal, vha, 0x00c8,
3767 + "Failed to allocate memory for ha->msix_entries.\n");
3768 + ret = -ENOMEM;
3769 +- goto msix_out;
3770 ++ goto free_irqs;
3771 + }
3772 + ha->flags.msix_enabled = 1;
3773 +
3774 +@@ -3477,6 +3477,10 @@ msix_register_fail:
3775 +
3776 + msix_out:
3777 + return ret;
3778 ++
3779 ++free_irqs:
3780 ++ pci_free_irq_vectors(ha->pdev);
3781 ++ goto msix_out;
3782 + }
3783 +
3784 + int
3785 +diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
3786 +index 9465acd18df0..2fcdaadd10fa 100644
3787 +--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
3788 ++++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
3789 +@@ -366,8 +366,9 @@ static void tcm_qla2xxx_close_session(struct se_session *se_sess)
3790 +
3791 + spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags);
3792 + target_sess_cmd_list_set_waiting(se_sess);
3793 +- tcm_qla2xxx_put_sess(sess);
3794 + spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags);
3795 ++
3796 ++ tcm_qla2xxx_put_sess(sess);
3797 + }
3798 +
3799 + static u32 tcm_qla2xxx_sess_get_index(struct se_session *se_sess)
3800 +@@ -391,6 +392,8 @@ static int tcm_qla2xxx_write_pending(struct se_cmd *se_cmd)
3801 + cmd->se_cmd.transport_state,
3802 + cmd->se_cmd.t_state,
3803 + cmd->se_cmd.se_cmd_flags);
3804 ++ transport_generic_request_failure(&cmd->se_cmd,
3805 ++ TCM_CHECK_CONDITION_ABORT_CMD);
3806 + return 0;
3807 + }
3808 + cmd->trc_flags |= TRC_XFR_RDY;
3809 +diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
3810 +index 630b7404843d..4421f9bdfcf7 100644
3811 +--- a/drivers/scsi/qla4xxx/ql4_os.c
3812 ++++ b/drivers/scsi/qla4xxx/ql4_os.c
3813 +@@ -5939,7 +5939,7 @@ static int get_fw_boot_info(struct scsi_qla_host *ha, uint16_t ddb_index[])
3814 + val = rd_nvram_byte(ha, sec_addr);
3815 + if (val & BIT_7)
3816 + ddb_index[1] = (val & 0x7f);
3817 +-
3818 ++ goto exit_boot_info;
3819 + } else if (is_qla80XX(ha)) {
3820 + buf = dma_alloc_coherent(&ha->pdev->dev, size,
3821 + &buf_dma, GFP_KERNEL);
3822 +diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
3823 +index e0c0fea227c1..3b70f7bb7fe6 100644
3824 +--- a/drivers/scsi/sd.c
3825 ++++ b/drivers/scsi/sd.c
3826 +@@ -2616,7 +2616,6 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer)
3827 + int res;
3828 + struct scsi_device *sdp = sdkp->device;
3829 + struct scsi_mode_data data;
3830 +- int disk_ro = get_disk_ro(sdkp->disk);
3831 + int old_wp = sdkp->write_prot;
3832 +
3833 + set_disk_ro(sdkp->disk, 0);
3834 +@@ -2657,7 +2656,7 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer)
3835 + "Test WP failed, assume Write Enabled\n");
3836 + } else {
3837 + sdkp->write_prot = ((data.device_specific & 0x80) != 0);
3838 +- set_disk_ro(sdkp->disk, sdkp->write_prot || disk_ro);
3839 ++ set_disk_ro(sdkp->disk, sdkp->write_prot);
3840 + if (sdkp->first_scan || old_wp != sdkp->write_prot) {
3841 + sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n",
3842 + sdkp->write_prot ? "on" : "off");
3843 +diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
3844 +index 581571de2461..d8f0a1ccd9b1 100644
3845 +--- a/drivers/scsi/ufs/ufshcd.c
3846 ++++ b/drivers/scsi/ufs/ufshcd.c
3847 +@@ -5911,19 +5911,19 @@ static u32 ufshcd_find_max_sup_active_icc_level(struct ufs_hba *hba,
3848 + goto out;
3849 + }
3850 +
3851 +- if (hba->vreg_info.vcc)
3852 ++ if (hba->vreg_info.vcc && hba->vreg_info.vcc->max_uA)
3853 + icc_level = ufshcd_get_max_icc_level(
3854 + hba->vreg_info.vcc->max_uA,
3855 + POWER_DESC_MAX_ACTV_ICC_LVLS - 1,
3856 + &desc_buf[PWR_DESC_ACTIVE_LVLS_VCC_0]);
3857 +
3858 +- if (hba->vreg_info.vccq)
3859 ++ if (hba->vreg_info.vccq && hba->vreg_info.vccq->max_uA)
3860 + icc_level = ufshcd_get_max_icc_level(
3861 + hba->vreg_info.vccq->max_uA,
3862 + icc_level,
3863 + &desc_buf[PWR_DESC_ACTIVE_LVLS_VCCQ_0]);
3864 +
3865 +- if (hba->vreg_info.vccq2)
3866 ++ if (hba->vreg_info.vccq2 && hba->vreg_info.vccq2->max_uA)
3867 + icc_level = ufshcd_get_max_icc_level(
3868 + hba->vreg_info.vccq2->max_uA,
3869 + icc_level,
3870 +@@ -6525,6 +6525,15 @@ static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg,
3871 + if (!vreg)
3872 + return 0;
3873 +
3874 ++ /*
3875 ++ * "set_load" operation shall be required on those regulators
3876 ++ * which specifically configured current limitation. Otherwise
3877 ++ * zero max_uA may cause unexpected behavior when regulator is
3878 ++ * enabled or set as high power mode.
3879 ++ */
3880 ++ if (!vreg->max_uA)
3881 ++ return 0;
3882 ++
3883 + ret = regulator_set_load(vreg->reg, ua);
3884 + if (ret < 0) {
3885 + dev_err(dev, "%s: %s set load (ua=%d) failed, err=%d\n",
3886 +@@ -6571,12 +6580,15 @@ static int ufshcd_config_vreg(struct device *dev,
3887 + name = vreg->name;
3888 +
3889 + if (regulator_count_voltages(reg) > 0) {
3890 +- min_uV = on ? vreg->min_uV : 0;
3891 +- ret = regulator_set_voltage(reg, min_uV, vreg->max_uV);
3892 +- if (ret) {
3893 +- dev_err(dev, "%s: %s set voltage failed, err=%d\n",
3894 ++ if (vreg->min_uV && vreg->max_uV) {
3895 ++ min_uV = on ? vreg->min_uV : 0;
3896 ++ ret = regulator_set_voltage(reg, min_uV, vreg->max_uV);
3897 ++ if (ret) {
3898 ++ dev_err(dev,
3899 ++ "%s: %s set voltage failed, err=%d\n",
3900 + __func__, name, ret);
3901 +- goto out;
3902 ++ goto out;
3903 ++ }
3904 + }
3905 +
3906 + uA_load = on ? vreg->max_uA : 0;
3907 +diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
3908 +index c0e915d8da5d..efdae686a761 100644
3909 +--- a/drivers/spi/spi-pxa2xx.c
3910 ++++ b/drivers/spi/spi-pxa2xx.c
3911 +@@ -938,10 +938,14 @@ static unsigned int ssp_get_clk_div(struct driver_data *drv_data, int rate)
3912 +
3913 + rate = min_t(int, ssp_clk, rate);
3914 +
3915 ++ /*
3916 ++ * Calculate the divisor for the SCR (Serial Clock Rate), avoiding
3917 ++ * that the SSP transmission rate can be greater than the device rate
3918 ++ */
3919 + if (ssp->type == PXA25x_SSP || ssp->type == CE4100_SSP)
3920 +- return (ssp_clk / (2 * rate) - 1) & 0xff;
3921 ++ return (DIV_ROUND_UP(ssp_clk, 2 * rate) - 1) & 0xff;
3922 + else
3923 +- return (ssp_clk / rate - 1) & 0xfff;
3924 ++ return (DIV_ROUND_UP(ssp_clk, rate) - 1) & 0xfff;
3925 + }
3926 +
3927 + static unsigned int pxa2xx_ssp_get_clk_div(struct driver_data *drv_data,
3928 +diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
3929 +index 20981e08ee97..f4a797a9d76e 100644
3930 +--- a/drivers/spi/spi-rspi.c
3931 ++++ b/drivers/spi/spi-rspi.c
3932 +@@ -279,7 +279,8 @@ static int rspi_set_config_register(struct rspi_data *rspi, int access_size)
3933 + /* Sets parity, interrupt mask */
3934 + rspi_write8(rspi, 0x00, RSPI_SPCR2);
3935 +
3936 +- /* Sets SPCMD */
3937 ++ /* Resets sequencer */
3938 ++ rspi_write8(rspi, 0, RSPI_SPSCR);
3939 + rspi->spcmd |= SPCMD_SPB_8_TO_16(access_size);
3940 + rspi_write16(rspi, rspi->spcmd, RSPI_SPCMD0);
3941 +
3942 +@@ -323,7 +324,8 @@ static int rspi_rz_set_config_register(struct rspi_data *rspi, int access_size)
3943 + rspi_write8(rspi, 0x00, RSPI_SSLND);
3944 + rspi_write8(rspi, 0x00, RSPI_SPND);
3945 +
3946 +- /* Sets SPCMD */
3947 ++ /* Resets sequencer */
3948 ++ rspi_write8(rspi, 0, RSPI_SPSCR);
3949 + rspi->spcmd |= SPCMD_SPB_8_TO_16(access_size);
3950 + rspi_write16(rspi, rspi->spcmd, RSPI_SPCMD0);
3951 +
3952 +@@ -374,7 +376,8 @@ static int qspi_set_config_register(struct rspi_data *rspi, int access_size)
3953 + /* Sets buffer to allow normal operation */
3954 + rspi_write8(rspi, 0x00, QSPI_SPBFCR);
3955 +
3956 +- /* Sets SPCMD */
3957 ++ /* Resets sequencer */
3958 ++ rspi_write8(rspi, 0, RSPI_SPSCR);
3959 + rspi_write16(rspi, rspi->spcmd, RSPI_SPCMD0);
3960 +
3961 + /* Enables SPI function in master mode */
3962 +diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c
3963 +index 44550182a4a3..2ad04796ef29 100644
3964 +--- a/drivers/spi/spi-tegra114.c
3965 ++++ b/drivers/spi/spi-tegra114.c
3966 +@@ -1067,27 +1067,19 @@ static int tegra_spi_probe(struct platform_device *pdev)
3967 +
3968 + spi_irq = platform_get_irq(pdev, 0);
3969 + tspi->irq = spi_irq;
3970 +- ret = request_threaded_irq(tspi->irq, tegra_spi_isr,
3971 +- tegra_spi_isr_thread, IRQF_ONESHOT,
3972 +- dev_name(&pdev->dev), tspi);
3973 +- if (ret < 0) {
3974 +- dev_err(&pdev->dev, "Failed to register ISR for IRQ %d\n",
3975 +- tspi->irq);
3976 +- goto exit_free_master;
3977 +- }
3978 +
3979 + tspi->clk = devm_clk_get(&pdev->dev, "spi");
3980 + if (IS_ERR(tspi->clk)) {
3981 + dev_err(&pdev->dev, "can not get clock\n");
3982 + ret = PTR_ERR(tspi->clk);
3983 +- goto exit_free_irq;
3984 ++ goto exit_free_master;
3985 + }
3986 +
3987 + tspi->rst = devm_reset_control_get_exclusive(&pdev->dev, "spi");
3988 + if (IS_ERR(tspi->rst)) {
3989 + dev_err(&pdev->dev, "can not get reset\n");
3990 + ret = PTR_ERR(tspi->rst);
3991 +- goto exit_free_irq;
3992 ++ goto exit_free_master;
3993 + }
3994 +
3995 + tspi->max_buf_size = SPI_FIFO_DEPTH << 2;
3996 +@@ -1095,7 +1087,7 @@ static int tegra_spi_probe(struct platform_device *pdev)
3997 +
3998 + ret = tegra_spi_init_dma_param(tspi, true);
3999 + if (ret < 0)
4000 +- goto exit_free_irq;
4001 ++ goto exit_free_master;
4002 + ret = tegra_spi_init_dma_param(tspi, false);
4003 + if (ret < 0)
4004 + goto exit_rx_dma_free;
4005 +@@ -1117,18 +1109,32 @@ static int tegra_spi_probe(struct platform_device *pdev)
4006 + dev_err(&pdev->dev, "pm runtime get failed, e = %d\n", ret);
4007 + goto exit_pm_disable;
4008 + }
4009 ++
4010 ++ reset_control_assert(tspi->rst);
4011 ++ udelay(2);
4012 ++ reset_control_deassert(tspi->rst);
4013 + tspi->def_command1_reg = SPI_M_S;
4014 + tegra_spi_writel(tspi, tspi->def_command1_reg, SPI_COMMAND1);
4015 + pm_runtime_put(&pdev->dev);
4016 ++ ret = request_threaded_irq(tspi->irq, tegra_spi_isr,
4017 ++ tegra_spi_isr_thread, IRQF_ONESHOT,
4018 ++ dev_name(&pdev->dev), tspi);
4019 ++ if (ret < 0) {
4020 ++ dev_err(&pdev->dev, "Failed to register ISR for IRQ %d\n",
4021 ++ tspi->irq);
4022 ++ goto exit_pm_disable;
4023 ++ }
4024 +
4025 + master->dev.of_node = pdev->dev.of_node;
4026 + ret = devm_spi_register_master(&pdev->dev, master);
4027 + if (ret < 0) {
4028 + dev_err(&pdev->dev, "can not register to master err %d\n", ret);
4029 +- goto exit_pm_disable;
4030 ++ goto exit_free_irq;
4031 + }
4032 + return ret;
4033 +
4034 ++exit_free_irq:
4035 ++ free_irq(spi_irq, tspi);
4036 + exit_pm_disable:
4037 + pm_runtime_disable(&pdev->dev);
4038 + if (!pm_runtime_status_suspended(&pdev->dev))
4039 +@@ -1136,8 +1142,6 @@ exit_pm_disable:
4040 + tegra_spi_deinit_dma_param(tspi, false);
4041 + exit_rx_dma_free:
4042 + tegra_spi_deinit_dma_param(tspi, true);
4043 +-exit_free_irq:
4044 +- free_irq(spi_irq, tspi);
4045 + exit_free_master:
4046 + spi_master_put(master);
4047 + return ret;
4048 +diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
4049 +index 97d137591b18..4389ab80c23e 100644
4050 +--- a/drivers/spi/spi-topcliff-pch.c
4051 ++++ b/drivers/spi/spi-topcliff-pch.c
4052 +@@ -1294,18 +1294,27 @@ static void pch_free_dma_buf(struct pch_spi_board_data *board_dat,
4053 + dma->rx_buf_virt, dma->rx_buf_dma);
4054 + }
4055 +
4056 +-static void pch_alloc_dma_buf(struct pch_spi_board_data *board_dat,
4057 ++static int pch_alloc_dma_buf(struct pch_spi_board_data *board_dat,
4058 + struct pch_spi_data *data)
4059 + {
4060 + struct pch_spi_dma_ctrl *dma;
4061 ++ int ret;
4062 +
4063 + dma = &data->dma;
4064 ++ ret = 0;
4065 + /* Get Consistent memory for Tx DMA */
4066 + dma->tx_buf_virt = dma_alloc_coherent(&board_dat->pdev->dev,
4067 + PCH_BUF_SIZE, &dma->tx_buf_dma, GFP_KERNEL);
4068 ++ if (!dma->tx_buf_virt)
4069 ++ ret = -ENOMEM;
4070 ++
4071 + /* Get Consistent memory for Rx DMA */
4072 + dma->rx_buf_virt = dma_alloc_coherent(&board_dat->pdev->dev,
4073 + PCH_BUF_SIZE, &dma->rx_buf_dma, GFP_KERNEL);
4074 ++ if (!dma->rx_buf_virt)
4075 ++ ret = -ENOMEM;
4076 ++
4077 ++ return ret;
4078 + }
4079 +
4080 + static int pch_spi_pd_probe(struct platform_device *plat_dev)
4081 +@@ -1382,7 +1391,9 @@ static int pch_spi_pd_probe(struct platform_device *plat_dev)
4082 +
4083 + if (use_dma) {
4084 + dev_info(&plat_dev->dev, "Use DMA for data transfers\n");
4085 +- pch_alloc_dma_buf(board_dat, data);
4086 ++ ret = pch_alloc_dma_buf(board_dat, data);
4087 ++ if (ret)
4088 ++ goto err_spi_register_master;
4089 + }
4090 +
4091 + ret = spi_register_master(master);
4092 +diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
4093 +index 670dbb7a8500..56035637d8f6 100644
4094 +--- a/drivers/spi/spi.c
4095 ++++ b/drivers/spi/spi.c
4096 +@@ -991,6 +991,8 @@ static int spi_map_msg(struct spi_controller *ctlr, struct spi_message *msg)
4097 + if (max_tx || max_rx) {
4098 + list_for_each_entry(xfer, &msg->transfers,
4099 + transfer_list) {
4100 ++ if (!xfer->len)
4101 ++ continue;
4102 + if (!xfer->tx_buf)
4103 + xfer->tx_buf = ctlr->dummy_tx;
4104 + if (!xfer->rx_buf)
4105 +diff --git a/drivers/ssb/bridge_pcmcia_80211.c b/drivers/ssb/bridge_pcmcia_80211.c
4106 +index d70568ea02d5..2ff7d90e166a 100644
4107 +--- a/drivers/ssb/bridge_pcmcia_80211.c
4108 ++++ b/drivers/ssb/bridge_pcmcia_80211.c
4109 +@@ -113,16 +113,21 @@ static struct pcmcia_driver ssb_host_pcmcia_driver = {
4110 + .resume = ssb_host_pcmcia_resume,
4111 + };
4112 +
4113 ++static int pcmcia_init_failed;
4114 ++
4115 + /*
4116 + * These are not module init/exit functions!
4117 + * The module_pcmcia_driver() helper cannot be used here.
4118 + */
4119 + int ssb_host_pcmcia_init(void)
4120 + {
4121 +- return pcmcia_register_driver(&ssb_host_pcmcia_driver);
4122 ++ pcmcia_init_failed = pcmcia_register_driver(&ssb_host_pcmcia_driver);
4123 ++
4124 ++ return pcmcia_init_failed;
4125 + }
4126 +
4127 + void ssb_host_pcmcia_exit(void)
4128 + {
4129 +- pcmcia_unregister_driver(&ssb_host_pcmcia_driver);
4130 ++ if (!pcmcia_init_failed)
4131 ++ pcmcia_unregister_driver(&ssb_host_pcmcia_driver);
4132 + }
4133 +diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
4134 +index 8bd137109980..fe2384b019ec 100644
4135 +--- a/drivers/thunderbolt/switch.c
4136 ++++ b/drivers/thunderbolt/switch.c
4137 +@@ -1206,13 +1206,14 @@ int tb_switch_configure(struct tb_switch *sw)
4138 + return tb_plug_events_active(sw, true);
4139 + }
4140 +
4141 +-static void tb_switch_set_uuid(struct tb_switch *sw)
4142 ++static int tb_switch_set_uuid(struct tb_switch *sw)
4143 + {
4144 + u32 uuid[4];
4145 +- int cap;
4146 ++ int cap, ret;
4147 +
4148 ++ ret = 0;
4149 + if (sw->uuid)
4150 +- return;
4151 ++ return ret;
4152 +
4153 + /*
4154 + * The newer controllers include fused UUID as part of link
4155 +@@ -1220,7 +1221,9 @@ static void tb_switch_set_uuid(struct tb_switch *sw)
4156 + */
4157 + cap = tb_switch_find_vse_cap(sw, TB_VSE_CAP_LINK_CONTROLLER);
4158 + if (cap > 0) {
4159 +- tb_sw_read(sw, uuid, TB_CFG_SWITCH, cap + 3, 4);
4160 ++ ret = tb_sw_read(sw, uuid, TB_CFG_SWITCH, cap + 3, 4);
4161 ++ if (ret)
4162 ++ return ret;
4163 + } else {
4164 + /*
4165 + * ICM generates UUID based on UID and fills the upper
4166 +@@ -1235,6 +1238,9 @@ static void tb_switch_set_uuid(struct tb_switch *sw)
4167 + }
4168 +
4169 + sw->uuid = kmemdup(uuid, sizeof(uuid), GFP_KERNEL);
4170 ++ if (!sw->uuid)
4171 ++ ret = -ENOMEM;
4172 ++ return ret;
4173 + }
4174 +
4175 + static int tb_switch_add_dma_port(struct tb_switch *sw)
4176 +@@ -1280,7 +1286,9 @@ static int tb_switch_add_dma_port(struct tb_switch *sw)
4177 +
4178 + if (status) {
4179 + tb_sw_info(sw, "switch flash authentication failed\n");
4180 +- tb_switch_set_uuid(sw);
4181 ++ ret = tb_switch_set_uuid(sw);
4182 ++ if (ret)
4183 ++ return ret;
4184 + nvm_set_auth_status(sw, status);
4185 + }
4186 +
4187 +@@ -1330,7 +1338,9 @@ int tb_switch_add(struct tb_switch *sw)
4188 + }
4189 + tb_sw_info(sw, "uid: %#llx\n", sw->uid);
4190 +
4191 +- tb_switch_set_uuid(sw);
4192 ++ ret = tb_switch_set_uuid(sw);
4193 ++ if (ret)
4194 ++ return ret;
4195 +
4196 + for (i = 0; i <= sw->config.max_port_number; i++) {
4197 + if (sw->ports[i].disabled) {
4198 +diff --git a/drivers/tty/ipwireless/main.c b/drivers/tty/ipwireless/main.c
4199 +index 655c7948261c..2fa4f9123469 100644
4200 +--- a/drivers/tty/ipwireless/main.c
4201 ++++ b/drivers/tty/ipwireless/main.c
4202 +@@ -113,6 +113,10 @@ static int ipwireless_probe(struct pcmcia_device *p_dev, void *priv_data)
4203 +
4204 + ipw->common_memory = ioremap(p_dev->resource[2]->start,
4205 + resource_size(p_dev->resource[2]));
4206 ++ if (!ipw->common_memory) {
4207 ++ ret = -ENOMEM;
4208 ++ goto exit1;
4209 ++ }
4210 + if (!request_mem_region(p_dev->resource[2]->start,
4211 + resource_size(p_dev->resource[2]),
4212 + IPWIRELESS_PCCARD_NAME)) {
4213 +@@ -133,6 +137,10 @@ static int ipwireless_probe(struct pcmcia_device *p_dev, void *priv_data)
4214 +
4215 + ipw->attr_memory = ioremap(p_dev->resource[3]->start,
4216 + resource_size(p_dev->resource[3]));
4217 ++ if (!ipw->attr_memory) {
4218 ++ ret = -ENOMEM;
4219 ++ goto exit3;
4220 ++ }
4221 + if (!request_mem_region(p_dev->resource[3]->start,
4222 + resource_size(p_dev->resource[3]),
4223 + IPWIRELESS_PCCARD_NAME)) {
4224 +diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
4225 +index d0b2e0ed9bab..5fcea1114e2f 100644
4226 +--- a/drivers/usb/core/hcd.c
4227 ++++ b/drivers/usb/core/hcd.c
4228 +@@ -3053,6 +3053,9 @@ usb_hcd_platform_shutdown(struct platform_device *dev)
4229 + {
4230 + struct usb_hcd *hcd = platform_get_drvdata(dev);
4231 +
4232 ++ /* No need for pm_runtime_put(), we're shutting down */
4233 ++ pm_runtime_get_sync(&dev->dev);
4234 ++
4235 + if (hcd->driver->shutdown)
4236 + hcd->driver->shutdown(hcd);
4237 + }
4238 +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
4239 +index a9541525ea4f..eddecaf1f0b2 100644
4240 +--- a/drivers/usb/core/hub.c
4241 ++++ b/drivers/usb/core/hub.c
4242 +@@ -5713,7 +5713,10 @@ int usb_reset_device(struct usb_device *udev)
4243 + cintf->needs_binding = 1;
4244 + }
4245 + }
4246 +- usb_unbind_and_rebind_marked_interfaces(udev);
4247 ++
4248 ++ /* If the reset failed, hub_wq will unbind drivers later */
4249 ++ if (ret == 0)
4250 ++ usb_unbind_and_rebind_marked_interfaces(udev);
4251 + }
4252 +
4253 + usb_autosuspend_device(udev);
4254 +diff --git a/drivers/video/fbdev/core/fbcmap.c b/drivers/video/fbdev/core/fbcmap.c
4255 +index 68a113594808..2811c4afde01 100644
4256 +--- a/drivers/video/fbdev/core/fbcmap.c
4257 ++++ b/drivers/video/fbdev/core/fbcmap.c
4258 +@@ -94,6 +94,8 @@ int fb_alloc_cmap_gfp(struct fb_cmap *cmap, int len, int transp, gfp_t flags)
4259 + int size = len * sizeof(u16);
4260 + int ret = -ENOMEM;
4261 +
4262 ++ flags |= __GFP_NOWARN;
4263 ++
4264 + if (cmap->len != len) {
4265 + fb_dealloc_cmap(cmap);
4266 + if (!len)
4267 +diff --git a/drivers/video/fbdev/core/modedb.c b/drivers/video/fbdev/core/modedb.c
4268 +index de119f11b78f..455a15f70172 100644
4269 +--- a/drivers/video/fbdev/core/modedb.c
4270 ++++ b/drivers/video/fbdev/core/modedb.c
4271 +@@ -933,6 +933,9 @@ void fb_var_to_videomode(struct fb_videomode *mode,
4272 + if (var->vmode & FB_VMODE_DOUBLE)
4273 + vtotal *= 2;
4274 +
4275 ++ if (!htotal || !vtotal)
4276 ++ return;
4277 ++
4278 + hfreq = pixclock/htotal;
4279 + mode->refresh = hfreq/vtotal;
4280 + }
4281 +diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c
4282 +index d191e1f80579..661551c4ffa2 100644
4283 +--- a/drivers/w1/w1_io.c
4284 ++++ b/drivers/w1/w1_io.c
4285 +@@ -430,8 +430,7 @@ int w1_reset_resume_command(struct w1_master *dev)
4286 + if (w1_reset_bus(dev))
4287 + return -1;
4288 +
4289 +- /* This will make only the last matched slave perform a skip ROM. */
4290 +- w1_write_8(dev, W1_RESUME_CMD);
4291 ++ w1_write_8(dev, dev->slave_count > 1 ? W1_RESUME_CMD : W1_SKIP_ROM);
4292 + return 0;
4293 + }
4294 + EXPORT_SYMBOL_GPL(w1_reset_resume_command);
4295 +diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
4296 +index 196503d8c993..d826fbaf7d50 100644
4297 +--- a/fs/btrfs/backref.c
4298 ++++ b/fs/btrfs/backref.c
4299 +@@ -718,7 +718,7 @@ out:
4300 + * read tree blocks and add keys where required.
4301 + */
4302 + static int add_missing_keys(struct btrfs_fs_info *fs_info,
4303 +- struct preftrees *preftrees)
4304 ++ struct preftrees *preftrees, bool lock)
4305 + {
4306 + struct prelim_ref *ref;
4307 + struct extent_buffer *eb;
4308 +@@ -742,12 +742,14 @@ static int add_missing_keys(struct btrfs_fs_info *fs_info,
4309 + free_extent_buffer(eb);
4310 + return -EIO;
4311 + }
4312 +- btrfs_tree_read_lock(eb);
4313 ++ if (lock)
4314 ++ btrfs_tree_read_lock(eb);
4315 + if (btrfs_header_level(eb) == 0)
4316 + btrfs_item_key_to_cpu(eb, &ref->key_for_search, 0);
4317 + else
4318 + btrfs_node_key_to_cpu(eb, &ref->key_for_search, 0);
4319 +- btrfs_tree_read_unlock(eb);
4320 ++ if (lock)
4321 ++ btrfs_tree_read_unlock(eb);
4322 + free_extent_buffer(eb);
4323 + prelim_ref_insert(fs_info, &preftrees->indirect, ref, NULL);
4324 + cond_resched();
4325 +@@ -1228,7 +1230,7 @@ again:
4326 +
4327 + btrfs_release_path(path);
4328 +
4329 +- ret = add_missing_keys(fs_info, &preftrees);
4330 ++ ret = add_missing_keys(fs_info, &preftrees, path->skip_locking == 0);
4331 + if (ret)
4332 + goto out;
4333 +
4334 +@@ -1290,9 +1292,14 @@ again:
4335 + }
4336 + btrfs_tree_read_lock(eb);
4337 + btrfs_set_lock_blocking_rw(eb, BTRFS_READ_LOCK);
4338 ++ if (!path->skip_locking) {
4339 ++ btrfs_tree_read_lock(eb);
4340 ++ btrfs_set_lock_blocking_rw(eb, BTRFS_READ_LOCK);
4341 ++ }
4342 + ret = find_extent_in_eb(eb, bytenr,
4343 + *extent_item_pos, &eie);
4344 +- btrfs_tree_read_unlock_blocking(eb);
4345 ++ if (!path->skip_locking)
4346 ++ btrfs_tree_read_unlock_blocking(eb);
4347 + free_extent_buffer(eb);
4348 + if (ret < 0)
4349 + goto out;
4350 +diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
4351 +index 54bb5d79723a..49766721b2b1 100644
4352 +--- a/fs/btrfs/extent-tree.c
4353 ++++ b/fs/btrfs/extent-tree.c
4354 +@@ -4087,8 +4087,7 @@ static int create_space_info(struct btrfs_fs_info *info, u64 flags,
4355 + info->space_info_kobj, "%s",
4356 + alloc_name(space_info->flags));
4357 + if (ret) {
4358 +- percpu_counter_destroy(&space_info->total_bytes_pinned);
4359 +- kfree(space_info);
4360 ++ kobject_put(&space_info->kobj);
4361 + return ret;
4362 + }
4363 +
4364 +@@ -11058,9 +11057,9 @@ int btrfs_error_unpin_extent_range(struct btrfs_fs_info *fs_info,
4365 + * transaction.
4366 + */
4367 + static int btrfs_trim_free_extents(struct btrfs_device *device,
4368 +- struct fstrim_range *range, u64 *trimmed)
4369 ++ u64 minlen, u64 *trimmed)
4370 + {
4371 +- u64 start = range->start, len = 0;
4372 ++ u64 start = 0, len = 0;
4373 + int ret;
4374 +
4375 + *trimmed = 0;
4376 +@@ -11096,8 +11095,8 @@ static int btrfs_trim_free_extents(struct btrfs_device *device,
4377 + refcount_inc(&trans->use_count);
4378 + spin_unlock(&fs_info->trans_lock);
4379 +
4380 +- ret = find_free_dev_extent_start(trans, device, range->minlen,
4381 +- start, &start, &len);
4382 ++ ret = find_free_dev_extent_start(trans, device, minlen, start,
4383 ++ &start, &len);
4384 + if (trans)
4385 + btrfs_put_transaction(trans);
4386 +
4387 +@@ -11109,16 +11108,6 @@ static int btrfs_trim_free_extents(struct btrfs_device *device,
4388 + break;
4389 + }
4390 +
4391 +- /* If we are out of the passed range break */
4392 +- if (start > range->start + range->len - 1) {
4393 +- mutex_unlock(&fs_info->chunk_mutex);
4394 +- ret = 0;
4395 +- break;
4396 +- }
4397 +-
4398 +- start = max(range->start, start);
4399 +- len = min(range->len, len);
4400 +-
4401 + ret = btrfs_issue_discard(device->bdev, start, len, &bytes);
4402 + up_read(&fs_info->commit_root_sem);
4403 + mutex_unlock(&fs_info->chunk_mutex);
4404 +@@ -11129,10 +11118,6 @@ static int btrfs_trim_free_extents(struct btrfs_device *device,
4405 + start += len;
4406 + *trimmed += bytes;
4407 +
4408 +- /* We've trimmed enough */
4409 +- if (*trimmed >= range->len)
4410 +- break;
4411 +-
4412 + if (fatal_signal_pending(current)) {
4413 + ret = -ERESTARTSYS;
4414 + break;
4415 +@@ -11216,7 +11201,8 @@ int btrfs_trim_fs(struct btrfs_fs_info *fs_info, struct fstrim_range *range)
4416 + mutex_lock(&fs_info->fs_devices->device_list_mutex);
4417 + devices = &fs_info->fs_devices->devices;
4418 + list_for_each_entry(device, devices, dev_list) {
4419 +- ret = btrfs_trim_free_extents(device, range, &group_trimmed);
4420 ++ ret = btrfs_trim_free_extents(device, range->minlen,
4421 ++ &group_trimmed);
4422 + if (ret) {
4423 + dev_failed++;
4424 + dev_ret = ret;
4425 +diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
4426 +index 57e25e83b81a..97958ecaeed9 100644
4427 +--- a/fs/btrfs/file.c
4428 ++++ b/fs/btrfs/file.c
4429 +@@ -2058,6 +2058,18 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
4430 + bool full_sync = 0;
4431 + u64 len;
4432 +
4433 ++ /*
4434 ++ * If the inode needs a full sync, make sure we use a full range to
4435 ++ * avoid log tree corruption, due to hole detection racing with ordered
4436 ++ * extent completion for adjacent ranges, and assertion failures during
4437 ++ * hole detection.
4438 ++ */
4439 ++ if (test_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
4440 ++ &BTRFS_I(inode)->runtime_flags)) {
4441 ++ start = 0;
4442 ++ end = LLONG_MAX;
4443 ++ }
4444 ++
4445 + /*
4446 + * The range length can be represented by u64, we have to do the typecasts
4447 + * to avoid signed overflow if it's [0, LLONG_MAX] eg. from fsync()
4448 +@@ -2964,6 +2976,7 @@ static long btrfs_fallocate(struct file *file, int mode,
4449 + ret = btrfs_qgroup_reserve_data(inode, &data_reserved,
4450 + cur_offset, last_byte - cur_offset);
4451 + if (ret < 0) {
4452 ++ cur_offset = last_byte;
4453 + free_extent_map(em);
4454 + break;
4455 + }
4456 +@@ -3034,7 +3047,7 @@ out:
4457 + /* Let go of our reservation. */
4458 + if (ret != 0)
4459 + btrfs_free_reserved_data_space(inode, data_reserved,
4460 +- alloc_start, alloc_end - cur_offset);
4461 ++ cur_offset, alloc_end - cur_offset);
4462 + extent_changeset_free(data_reserved);
4463 + return ret;
4464 + }
4465 +diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
4466 +index 5feb8b03ffe8..9fa6db6a6f7d 100644
4467 +--- a/fs/btrfs/relocation.c
4468 ++++ b/fs/btrfs/relocation.c
4469 +@@ -4403,27 +4403,36 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
4470 + mutex_lock(&fs_info->cleaner_mutex);
4471 + ret = relocate_block_group(rc);
4472 + mutex_unlock(&fs_info->cleaner_mutex);
4473 +- if (ret < 0) {
4474 ++ if (ret < 0)
4475 + err = ret;
4476 +- goto out;
4477 +- }
4478 +-
4479 +- if (rc->extents_found == 0)
4480 +- break;
4481 +-
4482 +- btrfs_info(fs_info, "found %llu extents", rc->extents_found);
4483 +
4484 ++ /*
4485 ++ * We may have gotten ENOSPC after we already dirtied some
4486 ++ * extents. If writeout happens while we're relocating a
4487 ++ * different block group we could end up hitting the
4488 ++ * BUG_ON(rc->stage == UPDATE_DATA_PTRS) in
4489 ++ * btrfs_reloc_cow_block. Make sure we write everything out
4490 ++ * properly so we don't trip over this problem, and then break
4491 ++ * out of the loop if we hit an error.
4492 ++ */
4493 + if (rc->stage == MOVE_DATA_EXTENTS && rc->found_file_extent) {
4494 + ret = btrfs_wait_ordered_range(rc->data_inode, 0,
4495 + (u64)-1);
4496 +- if (ret) {
4497 ++ if (ret)
4498 + err = ret;
4499 +- goto out;
4500 +- }
4501 + invalidate_mapping_pages(rc->data_inode->i_mapping,
4502 + 0, -1);
4503 + rc->stage = UPDATE_DATA_PTRS;
4504 + }
4505 ++
4506 ++ if (err < 0)
4507 ++ goto out;
4508 ++
4509 ++ if (rc->extents_found == 0)
4510 ++ break;
4511 ++
4512 ++ btrfs_info(fs_info, "found %llu extents", rc->extents_found);
4513 ++
4514 + }
4515 +
4516 + WARN_ON(rc->block_group->pinned > 0);
4517 +diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
4518 +index 95bcc3cce78f..7bae7cff150e 100644
4519 +--- a/fs/btrfs/root-tree.c
4520 ++++ b/fs/btrfs/root-tree.c
4521 +@@ -145,16 +145,17 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
4522 + return -ENOMEM;
4523 +
4524 + ret = btrfs_search_slot(trans, root, key, path, 0, 1);
4525 +- if (ret < 0) {
4526 +- btrfs_abort_transaction(trans, ret);
4527 ++ if (ret < 0)
4528 + goto out;
4529 +- }
4530 +
4531 +- if (ret != 0) {
4532 +- btrfs_print_leaf(path->nodes[0]);
4533 +- btrfs_crit(fs_info, "unable to update root key %llu %u %llu",
4534 +- key->objectid, key->type, key->offset);
4535 +- BUG_ON(1);
4536 ++ if (ret > 0) {
4537 ++ btrfs_crit(fs_info,
4538 ++ "unable to find root key (%llu %u %llu) in tree %llu",
4539 ++ key->objectid, key->type, key->offset,
4540 ++ root->root_key.objectid);
4541 ++ ret = -EUCLEAN;
4542 ++ btrfs_abort_transaction(trans, ret);
4543 ++ goto out;
4544 + }
4545 +
4546 + l = path->nodes[0];
4547 +diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
4548 +index 883881b16c86..f05341bda1d1 100644
4549 +--- a/fs/btrfs/sysfs.c
4550 ++++ b/fs/btrfs/sysfs.c
4551 +@@ -794,7 +794,12 @@ int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs,
4552 + fs_devs->fsid_kobj.kset = btrfs_kset;
4553 + error = kobject_init_and_add(&fs_devs->fsid_kobj,
4554 + &btrfs_ktype, parent, "%pU", fs_devs->fsid);
4555 +- return error;
4556 ++ if (error) {
4557 ++ kobject_put(&fs_devs->fsid_kobj);
4558 ++ return error;
4559 ++ }
4560 ++
4561 ++ return 0;
4562 + }
4563 +
4564 + int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
4565 +diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
4566 +index 9d72882b0f72..d19129e9e7ad 100644
4567 +--- a/fs/btrfs/tree-log.c
4568 ++++ b/fs/btrfs/tree-log.c
4569 +@@ -4012,6 +4012,7 @@ fill_holes:
4570 + *last_extent, 0,
4571 + 0, len, 0, len,
4572 + 0, 0, 0);
4573 ++ *last_extent += len;
4574 + }
4575 + }
4576 + }
4577 +diff --git a/fs/char_dev.c b/fs/char_dev.c
4578 +index a65e4a56318c..20ce45c7c57c 100644
4579 +--- a/fs/char_dev.c
4580 ++++ b/fs/char_dev.c
4581 +@@ -159,6 +159,12 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor,
4582 + ret = -EBUSY;
4583 + goto out;
4584 + }
4585 ++
4586 ++ if (new_min < old_min && new_max > old_max) {
4587 ++ ret = -EBUSY;
4588 ++ goto out;
4589 ++ }
4590 ++
4591 + }
4592 +
4593 + cd->next = *cp;
4594 +diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
4595 +index d3ef946df585..862766a1b080 100644
4596 +--- a/fs/ext4/inode.c
4597 ++++ b/fs/ext4/inode.c
4598 +@@ -5450,7 +5450,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
4599 + up_write(&EXT4_I(inode)->i_data_sem);
4600 + ext4_journal_stop(handle);
4601 + if (error) {
4602 +- if (orphan)
4603 ++ if (orphan && inode->i_nlink)
4604 + ext4_orphan_del(NULL, inode);
4605 + goto err_out;
4606 + }
4607 +diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
4608 +index 3d37124eb63e..113d1cd55119 100644
4609 +--- a/fs/f2fs/data.c
4610 ++++ b/fs/f2fs/data.c
4611 +@@ -133,12 +133,14 @@ struct block_device *f2fs_target_device(struct f2fs_sb_info *sbi,
4612 + struct block_device *bdev = sbi->sb->s_bdev;
4613 + int i;
4614 +
4615 +- for (i = 0; i < sbi->s_ndevs; i++) {
4616 +- if (FDEV(i).start_blk <= blk_addr &&
4617 +- FDEV(i).end_blk >= blk_addr) {
4618 +- blk_addr -= FDEV(i).start_blk;
4619 +- bdev = FDEV(i).bdev;
4620 +- break;
4621 ++ if (f2fs_is_multi_device(sbi)) {
4622 ++ for (i = 0; i < sbi->s_ndevs; i++) {
4623 ++ if (FDEV(i).start_blk <= blk_addr &&
4624 ++ FDEV(i).end_blk >= blk_addr) {
4625 ++ blk_addr -= FDEV(i).start_blk;
4626 ++ bdev = FDEV(i).bdev;
4627 ++ break;
4628 ++ }
4629 + }
4630 + }
4631 + if (bio) {
4632 +@@ -152,6 +154,9 @@ int f2fs_target_device_index(struct f2fs_sb_info *sbi, block_t blkaddr)
4633 + {
4634 + int i;
4635 +
4636 ++ if (!f2fs_is_multi_device(sbi))
4637 ++ return 0;
4638 ++
4639 + for (i = 0; i < sbi->s_ndevs; i++)
4640 + if (FDEV(i).start_blk <= blkaddr && FDEV(i).end_blk >= blkaddr)
4641 + return i;
4642 +diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
4643 +index 634165fb64f1..406d93b51a0b 100644
4644 +--- a/fs/f2fs/f2fs.h
4645 ++++ b/fs/f2fs/f2fs.h
4646 +@@ -1167,6 +1167,17 @@ static inline bool time_to_inject(struct f2fs_sb_info *sbi, int type)
4647 + }
4648 + #endif
4649 +
4650 ++/*
4651 ++ * Test if the mounted volume is a multi-device volume.
4652 ++ * - For a single regular disk volume, sbi->s_ndevs is 0.
4653 ++ * - For a single zoned disk volume, sbi->s_ndevs is 1.
4654 ++ * - For a multi-device volume, sbi->s_ndevs is always 2 or more.
4655 ++ */
4656 ++static inline bool f2fs_is_multi_device(struct f2fs_sb_info *sbi)
4657 ++{
4658 ++ return sbi->s_ndevs > 1;
4659 ++}
4660 ++
4661 + /* For write statistics. Suppose sector size is 512 bytes,
4662 + * and the return value is in kbytes. s is of struct f2fs_sb_info.
4663 + */
4664 +diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
4665 +index 5f549bc4e097..1b1792199445 100644
4666 +--- a/fs/f2fs/file.c
4667 ++++ b/fs/f2fs/file.c
4668 +@@ -2407,7 +2407,7 @@ static int f2fs_ioc_flush_device(struct file *filp, unsigned long arg)
4669 + sizeof(range)))
4670 + return -EFAULT;
4671 +
4672 +- if (sbi->s_ndevs <= 1 || sbi->s_ndevs - 1 <= range.dev_num ||
4673 ++ if (!f2fs_is_multi_device(sbi) || sbi->s_ndevs - 1 <= range.dev_num ||
4674 + sbi->segs_per_sec != 1) {
4675 + f2fs_msg(sbi->sb, KERN_WARNING,
4676 + "Can't flush %u in %d for segs_per_sec %u != 1\n",
4677 +diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
4678 +index f22884418e92..ceb6023786bd 100644
4679 +--- a/fs/f2fs/gc.c
4680 ++++ b/fs/f2fs/gc.c
4681 +@@ -1111,7 +1111,7 @@ void build_gc_manager(struct f2fs_sb_info *sbi)
4682 + BLKS_PER_SEC(sbi), (main_count - resv_count));
4683 +
4684 + /* give warm/cold data area from slower device */
4685 +- if (sbi->s_ndevs && sbi->segs_per_sec == 1)
4686 ++ if (f2fs_is_multi_device(sbi) && sbi->segs_per_sec == 1)
4687 + SIT_I(sbi)->last_victim[ALLOC_NEXT] =
4688 + GET_SEGNO(sbi, FDEV(0).end_blk) + 1;
4689 + }
4690 +diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
4691 +index 5c698757e116..70bd15cadb44 100644
4692 +--- a/fs/f2fs/segment.c
4693 ++++ b/fs/f2fs/segment.c
4694 +@@ -495,7 +495,7 @@ static int submit_flush_wait(struct f2fs_sb_info *sbi)
4695 + int ret = __submit_flush_wait(sbi, sbi->sb->s_bdev);
4696 + int i;
4697 +
4698 +- if (!sbi->s_ndevs || ret)
4699 ++ if (!f2fs_is_multi_device(sbi) || ret)
4700 + return ret;
4701 +
4702 + for (i = 1; i < sbi->s_ndevs; i++) {
4703 +@@ -1050,7 +1050,7 @@ static int __queue_discard_cmd(struct f2fs_sb_info *sbi,
4704 +
4705 + trace_f2fs_queue_discard(bdev, blkstart, blklen);
4706 +
4707 +- if (sbi->s_ndevs) {
4708 ++ if (f2fs_is_multi_device(sbi)) {
4709 + int devi = f2fs_target_device_index(sbi, blkstart);
4710 +
4711 + blkstart -= FDEV(devi).start_blk;
4712 +@@ -1283,7 +1283,7 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
4713 + block_t lblkstart = blkstart;
4714 + int devi = 0;
4715 +
4716 +- if (sbi->s_ndevs) {
4717 ++ if (f2fs_is_multi_device(sbi)) {
4718 + devi = f2fs_target_device_index(sbi, blkstart);
4719 + blkstart -= FDEV(devi).start_blk;
4720 + }
4721 +diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
4722 +index d5284d0dbdb5..aea1ed0aebd0 100644
4723 +--- a/fs/gfs2/glock.c
4724 ++++ b/fs/gfs2/glock.c
4725 +@@ -140,6 +140,7 @@ void gfs2_glock_free(struct gfs2_glock *gl)
4726 + {
4727 + struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
4728 +
4729 ++ BUG_ON(atomic_read(&gl->gl_revokes));
4730 + rhashtable_remove_fast(&gl_hash_table, &gl->gl_node, ht_parms);
4731 + smp_mb();
4732 + wake_up_glock(gl);
4733 +@@ -183,15 +184,19 @@ static int demote_ok(const struct gfs2_glock *gl)
4734 +
4735 + void gfs2_glock_add_to_lru(struct gfs2_glock *gl)
4736 + {
4737 ++ if (!(gl->gl_ops->go_flags & GLOF_LRU))
4738 ++ return;
4739 ++
4740 + spin_lock(&lru_lock);
4741 +
4742 +- if (!list_empty(&gl->gl_lru))
4743 +- list_del_init(&gl->gl_lru);
4744 +- else
4745 ++ list_del(&gl->gl_lru);
4746 ++ list_add_tail(&gl->gl_lru, &lru_list);
4747 ++
4748 ++ if (!test_bit(GLF_LRU, &gl->gl_flags)) {
4749 ++ set_bit(GLF_LRU, &gl->gl_flags);
4750 + atomic_inc(&lru_count);
4751 ++ }
4752 +
4753 +- list_add_tail(&gl->gl_lru, &lru_list);
4754 +- set_bit(GLF_LRU, &gl->gl_flags);
4755 + spin_unlock(&lru_lock);
4756 + }
4757 +
4758 +@@ -201,7 +206,7 @@ static void gfs2_glock_remove_from_lru(struct gfs2_glock *gl)
4759 + return;
4760 +
4761 + spin_lock(&lru_lock);
4762 +- if (!list_empty(&gl->gl_lru)) {
4763 ++ if (test_bit(GLF_LRU, &gl->gl_flags)) {
4764 + list_del_init(&gl->gl_lru);
4765 + atomic_dec(&lru_count);
4766 + clear_bit(GLF_LRU, &gl->gl_flags);
4767 +@@ -1158,8 +1163,7 @@ void gfs2_glock_dq(struct gfs2_holder *gh)
4768 + !test_bit(GLF_DEMOTE, &gl->gl_flags))
4769 + fast_path = 1;
4770 + }
4771 +- if (!test_bit(GLF_LFLUSH, &gl->gl_flags) && demote_ok(gl) &&
4772 +- (glops->go_flags & GLOF_LRU))
4773 ++ if (!test_bit(GLF_LFLUSH, &gl->gl_flags) && demote_ok(gl))
4774 + gfs2_glock_add_to_lru(gl);
4775 +
4776 + trace_gfs2_glock_queue(gh, 0);
4777 +@@ -1454,6 +1458,7 @@ __acquires(&lru_lock)
4778 + if (!spin_trylock(&gl->gl_lockref.lock)) {
4779 + add_back_to_lru:
4780 + list_add(&gl->gl_lru, &lru_list);
4781 ++ set_bit(GLF_LRU, &gl->gl_flags);
4782 + atomic_inc(&lru_count);
4783 + continue;
4784 + }
4785 +@@ -1461,7 +1466,6 @@ add_back_to_lru:
4786 + spin_unlock(&gl->gl_lockref.lock);
4787 + goto add_back_to_lru;
4788 + }
4789 +- clear_bit(GLF_LRU, &gl->gl_flags);
4790 + gl->gl_lockref.count++;
4791 + if (demote_ok(gl))
4792 + handle_callback(gl, LM_ST_UNLOCKED, 0, false);
4793 +@@ -1496,6 +1500,7 @@ static long gfs2_scan_glock_lru(int nr)
4794 + if (!test_bit(GLF_LOCK, &gl->gl_flags)) {
4795 + list_move(&gl->gl_lru, &dispose);
4796 + atomic_dec(&lru_count);
4797 ++ clear_bit(GLF_LRU, &gl->gl_flags);
4798 + freed++;
4799 + continue;
4800 + }
4801 +diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c
4802 +index 65f33a0ac190..6f5c033fe4b5 100644
4803 +--- a/fs/gfs2/lock_dlm.c
4804 ++++ b/fs/gfs2/lock_dlm.c
4805 +@@ -31,9 +31,10 @@
4806 + * @delta is the difference between the current rtt sample and the
4807 + * running average srtt. We add 1/8 of that to the srtt in order to
4808 + * update the current srtt estimate. The variance estimate is a bit
4809 +- * more complicated. We subtract the abs value of the @delta from
4810 +- * the current variance estimate and add 1/4 of that to the running
4811 +- * total.
4812 ++ * more complicated. We subtract the current variance estimate from
4813 ++ * the abs value of the @delta and add 1/4 of that to the running
4814 ++ * total. That's equivalent to 3/4 of the current variance
4815 ++ * estimate plus 1/4 of the abs of @delta.
4816 + *
4817 + * Note that the index points at the array entry containing the smoothed
4818 + * mean value, and the variance is always in the following entry
4819 +@@ -49,7 +50,7 @@ static inline void gfs2_update_stats(struct gfs2_lkstats *s, unsigned index,
4820 + s64 delta = sample - s->stats[index];
4821 + s->stats[index] += (delta >> 3);
4822 + index++;
4823 +- s->stats[index] += ((abs(delta) - s->stats[index]) >> 2);
4824 ++ s->stats[index] += (s64)(abs(delta) - s->stats[index]) >> 2;
4825 + }
4826 +
4827 + /**
4828 +diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
4829 +index f72c44231406..483b82e2be92 100644
4830 +--- a/fs/gfs2/log.c
4831 ++++ b/fs/gfs2/log.c
4832 +@@ -588,7 +588,8 @@ void gfs2_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
4833 + bd->bd_bh = NULL;
4834 + bd->bd_ops = &gfs2_revoke_lops;
4835 + sdp->sd_log_num_revoke++;
4836 +- atomic_inc(&gl->gl_revokes);
4837 ++ if (atomic_inc_return(&gl->gl_revokes) == 1)
4838 ++ gfs2_glock_hold(gl);
4839 + set_bit(GLF_LFLUSH, &gl->gl_flags);
4840 + list_add(&bd->bd_list, &sdp->sd_log_le_revoke);
4841 + }
4842 +diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
4843 +index c8ff7b7954f0..049f8c6721b4 100644
4844 +--- a/fs/gfs2/lops.c
4845 ++++ b/fs/gfs2/lops.c
4846 +@@ -660,8 +660,10 @@ static void revoke_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
4847 + bd = list_entry(head->next, struct gfs2_bufdata, bd_list);
4848 + list_del_init(&bd->bd_list);
4849 + gl = bd->bd_gl;
4850 +- atomic_dec(&gl->gl_revokes);
4851 +- clear_bit(GLF_LFLUSH, &gl->gl_flags);
4852 ++ if (atomic_dec_return(&gl->gl_revokes) == 0) {
4853 ++ clear_bit(GLF_LFLUSH, &gl->gl_flags);
4854 ++ gfs2_glock_queue_put(gl);
4855 ++ }
4856 + kmem_cache_free(gfs2_bufdata_cachep, bd);
4857 + }
4858 + }
4859 +diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
4860 +index dd28a9b287da..ba54a0e12bbd 100644
4861 +--- a/fs/hugetlbfs/inode.c
4862 ++++ b/fs/hugetlbfs/inode.c
4863 +@@ -436,9 +436,7 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
4864 + u32 hash;
4865 +
4866 + index = page->index;
4867 +- hash = hugetlb_fault_mutex_hash(h, current->mm,
4868 +- &pseudo_vma,
4869 +- mapping, index, 0);
4870 ++ hash = hugetlb_fault_mutex_hash(h, mapping, index, 0);
4871 + mutex_lock(&hugetlb_fault_mutex_table[hash]);
4872 +
4873 + /*
4874 +@@ -557,7 +555,6 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
4875 + struct address_space *mapping = inode->i_mapping;
4876 + struct hstate *h = hstate_inode(inode);
4877 + struct vm_area_struct pseudo_vma;
4878 +- struct mm_struct *mm = current->mm;
4879 + loff_t hpage_size = huge_page_size(h);
4880 + unsigned long hpage_shift = huge_page_shift(h);
4881 + pgoff_t start, index, end;
4882 +@@ -621,8 +618,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
4883 + addr = index * hpage_size;
4884 +
4885 + /* mutex taken here, fault path and hole punch */
4886 +- hash = hugetlb_fault_mutex_hash(h, mm, &pseudo_vma, mapping,
4887 +- index, addr);
4888 ++ hash = hugetlb_fault_mutex_hash(h, mapping, index, addr);
4889 + mutex_lock(&hugetlb_fault_mutex_table[hash]);
4890 +
4891 + /* See if already present in mapping to avoid alloc/free */
4892 +diff --git a/fs/nfs/client.c b/fs/nfs/client.c
4893 +index a98d64a6eda5..0c7008fb6d5a 100644
4894 +--- a/fs/nfs/client.c
4895 ++++ b/fs/nfs/client.c
4896 +@@ -290,6 +290,7 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat
4897 + struct nfs_client *clp;
4898 + const struct sockaddr *sap = data->addr;
4899 + struct nfs_net *nn = net_generic(data->net, nfs_net_id);
4900 ++ int error;
4901 +
4902 + again:
4903 + list_for_each_entry(clp, &nn->nfs_client_list, cl_share_link) {
4904 +@@ -302,9 +303,11 @@ again:
4905 + if (clp->cl_cons_state > NFS_CS_READY) {
4906 + atomic_inc(&clp->cl_count);
4907 + spin_unlock(&nn->nfs_client_lock);
4908 +- nfs_wait_client_init_complete(clp);
4909 ++ error = nfs_wait_client_init_complete(clp);
4910 + nfs_put_client(clp);
4911 + spin_lock(&nn->nfs_client_lock);
4912 ++ if (error < 0)
4913 ++ return ERR_PTR(error);
4914 + goto again;
4915 + }
4916 +
4917 +@@ -413,6 +416,8 @@ struct nfs_client *nfs_get_client(const struct nfs_client_initdata *cl_init)
4918 + clp = nfs_match_client(cl_init);
4919 + if (clp) {
4920 + spin_unlock(&nn->nfs_client_lock);
4921 ++ if (IS_ERR(clp))
4922 ++ return clp;
4923 + if (new)
4924 + new->rpc_ops->free_client(new);
4925 + return nfs_found_client(cl_init, clp);
4926 +diff --git a/include/linux/bio.h b/include/linux/bio.h
4927 +index 5aa40f4712ff..d4b39caf081d 100644
4928 +--- a/include/linux/bio.h
4929 ++++ b/include/linux/bio.h
4930 +@@ -260,7 +260,7 @@ static inline void bio_cnt_set(struct bio *bio, unsigned int count)
4931 + {
4932 + if (count != 1) {
4933 + bio->bi_flags |= (1 << BIO_REFFED);
4934 +- smp_mb__before_atomic();
4935 ++ smp_mb();
4936 + }
4937 + atomic_set(&bio->__bi_cnt, count);
4938 + }
4939 +diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h
4940 +index 93a2469a9130..eb396f71285f 100644
4941 +--- a/include/linux/cgroup-defs.h
4942 ++++ b/include/linux/cgroup-defs.h
4943 +@@ -287,6 +287,11 @@ struct cgroup {
4944 + * Dying cgroups are cgroups which were deleted by a user,
4945 + * but are still existing because someone else is holding a reference.
4946 + * max_descendants is a maximum allowed number of descent cgroups.
4947 ++ *
4948 ++ * nr_descendants and nr_dying_descendants are protected
4949 ++ * by cgroup_mutex and css_set_lock. It's fine to read them holding
4950 ++ * any of cgroup_mutex and css_set_lock; for writing both locks
4951 ++ * should be held.
4952 + */
4953 + int nr_descendants;
4954 + int nr_dying_descendants;
4955 +diff --git a/include/linux/hid.h b/include/linux/hid.h
4956 +index 06e6e04e6c11..3656a04d764b 100644
4957 +--- a/include/linux/hid.h
4958 ++++ b/include/linux/hid.h
4959 +@@ -398,6 +398,7 @@ struct hid_global {
4960 +
4961 + struct hid_local {
4962 + unsigned usage[HID_MAX_USAGES]; /* usage array */
4963 ++ u8 usage_size[HID_MAX_USAGES]; /* usage size array */
4964 + unsigned collection_index[HID_MAX_USAGES]; /* collection index array */
4965 + unsigned usage_index;
4966 + unsigned usage_minimum;
4967 +diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
4968 +index 7aa2de25c09c..50a07235032f 100644
4969 +--- a/include/linux/hugetlb.h
4970 ++++ b/include/linux/hugetlb.h
4971 +@@ -122,9 +122,7 @@ void putback_active_hugepage(struct page *page);
4972 + void free_huge_page(struct page *page);
4973 + void hugetlb_fix_reserve_counts(struct inode *inode);
4974 + extern struct mutex *hugetlb_fault_mutex_table;
4975 +-u32 hugetlb_fault_mutex_hash(struct hstate *h, struct mm_struct *mm,
4976 +- struct vm_area_struct *vma,
4977 +- struct address_space *mapping,
4978 ++u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping,
4979 + pgoff_t idx, unsigned long address);
4980 +
4981 + pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud);
4982 +diff --git a/include/linux/iio/adc/ad_sigma_delta.h b/include/linux/iio/adc/ad_sigma_delta.h
4983 +index 1fc7abd28b0b..7b7157c26d31 100644
4984 +--- a/include/linux/iio/adc/ad_sigma_delta.h
4985 ++++ b/include/linux/iio/adc/ad_sigma_delta.h
4986 +@@ -66,6 +66,7 @@ struct ad_sigma_delta {
4987 + bool irq_dis;
4988 +
4989 + bool bus_locked;
4990 ++ bool keep_cs_asserted;
4991 +
4992 + uint8_t comm;
4993 +
4994 +diff --git a/include/linux/smpboot.h b/include/linux/smpboot.h
4995 +index c174844cf663..585e777a7f6e 100644
4996 +--- a/include/linux/smpboot.h
4997 ++++ b/include/linux/smpboot.h
4998 +@@ -31,7 +31,7 @@ struct smpboot_thread_data;
4999 + * @thread_comm: The base name of the thread
5000 + */
5001 + struct smp_hotplug_thread {
5002 +- struct task_struct __percpu **store;
5003 ++ struct task_struct * __percpu *store;
5004 + struct list_head list;
5005 + int (*thread_should_run)(unsigned int cpu);
5006 + void (*thread_fn)(unsigned int cpu);
5007 +diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
5008 +index 8dd4063647c2..215c6e1ee026 100644
5009 +--- a/kernel/auditfilter.c
5010 ++++ b/kernel/auditfilter.c
5011 +@@ -1094,22 +1094,24 @@ int audit_rule_change(int type, int seq, void *data, size_t datasz)
5012 + int err = 0;
5013 + struct audit_entry *entry;
5014 +
5015 +- entry = audit_data_to_entry(data, datasz);
5016 +- if (IS_ERR(entry))
5017 +- return PTR_ERR(entry);
5018 +-
5019 + switch (type) {
5020 + case AUDIT_ADD_RULE:
5021 ++ entry = audit_data_to_entry(data, datasz);
5022 ++ if (IS_ERR(entry))
5023 ++ return PTR_ERR(entry);
5024 + err = audit_add_rule(entry);
5025 + audit_log_rule_change("add_rule", &entry->rule, !err);
5026 + break;
5027 + case AUDIT_DEL_RULE:
5028 ++ entry = audit_data_to_entry(data, datasz);
5029 ++ if (IS_ERR(entry))
5030 ++ return PTR_ERR(entry);
5031 + err = audit_del_rule(entry);
5032 + audit_log_rule_change("remove_rule", &entry->rule, !err);
5033 + break;
5034 + default:
5035 +- err = -EINVAL;
5036 + WARN_ON(1);
5037 ++ return -EINVAL;
5038 + }
5039 +
5040 + if (err || type == AUDIT_DEL_RULE) {
5041 +diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
5042 +index e745d6a88224..482bf42e21a4 100644
5043 +--- a/kernel/bpf/devmap.c
5044 ++++ b/kernel/bpf/devmap.c
5045 +@@ -156,6 +156,9 @@ static void dev_map_free(struct bpf_map *map)
5046 +
5047 + synchronize_rcu();
5048 +
5049 ++ /* Make sure prior __dev_map_entry_free() have completed. */
5050 ++ rcu_barrier();
5051 ++
5052 + /* To ensure all pending flush operations have completed wait for flush
5053 + * bitmap to indicate all flush_needed bits to be zero on _all_ cpus.
5054 + * Because the above synchronize_rcu() ensures the map is disconnected
5055 +diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
5056 +index 694b1cc8d144..d30a51da94e2 100644
5057 +--- a/kernel/cgroup/cgroup.c
5058 ++++ b/kernel/cgroup/cgroup.c
5059 +@@ -4546,9 +4546,11 @@ static void css_release_work_fn(struct work_struct *work)
5060 + /* cgroup release path */
5061 + trace_cgroup_release(cgrp);
5062 +
5063 ++ spin_lock_irq(&css_set_lock);
5064 + for (tcgrp = cgroup_parent(cgrp); tcgrp;
5065 + tcgrp = cgroup_parent(tcgrp))
5066 + tcgrp->nr_dying_descendants--;
5067 ++ spin_unlock_irq(&css_set_lock);
5068 +
5069 + cgroup_idr_remove(&cgrp->root->cgroup_idr, cgrp->id);
5070 + cgrp->id = -1;
5071 +@@ -4745,12 +4747,14 @@ static struct cgroup *cgroup_create(struct cgroup *parent)
5072 + cgrp->root = root;
5073 + cgrp->level = level;
5074 +
5075 ++ spin_lock_irq(&css_set_lock);
5076 + for (tcgrp = cgrp; tcgrp; tcgrp = cgroup_parent(tcgrp)) {
5077 + cgrp->ancestor_ids[tcgrp->level] = tcgrp->id;
5078 +
5079 + if (tcgrp != cgrp)
5080 + tcgrp->nr_descendants++;
5081 + }
5082 ++ spin_unlock_irq(&css_set_lock);
5083 +
5084 + if (notify_on_release(parent))
5085 + set_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags);
5086 +@@ -5033,10 +5037,12 @@ static int cgroup_destroy_locked(struct cgroup *cgrp)
5087 + if (parent && cgroup_is_threaded(cgrp))
5088 + parent->nr_threaded_children--;
5089 +
5090 ++ spin_lock_irq(&css_set_lock);
5091 + for (tcgrp = cgroup_parent(cgrp); tcgrp; tcgrp = cgroup_parent(tcgrp)) {
5092 + tcgrp->nr_descendants--;
5093 + tcgrp->nr_dying_descendants++;
5094 + }
5095 ++ spin_unlock_irq(&css_set_lock);
5096 +
5097 + cgroup1_check_for_release(parent);
5098 +
5099 +diff --git a/kernel/rcu/rcuperf.c b/kernel/rcu/rcuperf.c
5100 +index 1f87a02c3399..9b0d38812eb6 100644
5101 +--- a/kernel/rcu/rcuperf.c
5102 ++++ b/kernel/rcu/rcuperf.c
5103 +@@ -542,6 +542,10 @@ rcu_perf_cleanup(void)
5104 +
5105 + if (torture_cleanup_begin())
5106 + return;
5107 ++ if (!cur_ops) {
5108 ++ torture_cleanup_end();
5109 ++ return;
5110 ++ }
5111 +
5112 + if (reader_tasks) {
5113 + for (i = 0; i < nrealreaders; i++)
5114 +@@ -663,6 +667,7 @@ rcu_perf_init(void)
5115 + pr_alert(" %s", perf_ops[i]->name);
5116 + pr_alert("\n");
5117 + firsterr = -EINVAL;
5118 ++ cur_ops = NULL;
5119 + goto unwind;
5120 + }
5121 + if (cur_ops->init)
5122 +diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
5123 +index 45f2ffbc1e78..f0c599bf4058 100644
5124 +--- a/kernel/rcu/rcutorture.c
5125 ++++ b/kernel/rcu/rcutorture.c
5126 +@@ -1599,6 +1599,10 @@ rcu_torture_cleanup(void)
5127 + cur_ops->cb_barrier();
5128 + return;
5129 + }
5130 ++ if (!cur_ops) {
5131 ++ torture_cleanup_end();
5132 ++ return;
5133 ++ }
5134 +
5135 + rcu_torture_barrier_cleanup();
5136 + torture_stop_kthread(rcu_torture_stall, stall_task);
5137 +@@ -1734,6 +1738,7 @@ rcu_torture_init(void)
5138 + pr_alert(" %s", torture_ops[i]->name);
5139 + pr_alert("\n");
5140 + firsterr = -EINVAL;
5141 ++ cur_ops = NULL;
5142 + goto unwind;
5143 + }
5144 + if (cur_ops->fqs == NULL && fqs_duration != 0) {
5145 +diff --git a/kernel/sched/core.c b/kernel/sched/core.c
5146 +index 0552ddbb25e2..b3ff73d6a4c2 100644
5147 +--- a/kernel/sched/core.c
5148 ++++ b/kernel/sched/core.c
5149 +@@ -6380,6 +6380,8 @@ static void cpu_cgroup_attach(struct cgroup_taskset *tset)
5150 + static int cpu_shares_write_u64(struct cgroup_subsys_state *css,
5151 + struct cftype *cftype, u64 shareval)
5152 + {
5153 ++ if (shareval > scale_load_down(ULONG_MAX))
5154 ++ shareval = MAX_SHARES;
5155 + return sched_group_set_shares(css_tg(css), scale_load(shareval));
5156 + }
5157 +
5158 +@@ -6482,8 +6484,10 @@ int tg_set_cfs_quota(struct task_group *tg, long cfs_quota_us)
5159 + period = ktime_to_ns(tg->cfs_bandwidth.period);
5160 + if (cfs_quota_us < 0)
5161 + quota = RUNTIME_INF;
5162 +- else
5163 ++ else if ((u64)cfs_quota_us <= U64_MAX / NSEC_PER_USEC)
5164 + quota = (u64)cfs_quota_us * NSEC_PER_USEC;
5165 ++ else
5166 ++ return -EINVAL;
5167 +
5168 + return tg_set_cfs_bandwidth(tg, period, quota);
5169 + }
5170 +@@ -6505,6 +6509,9 @@ int tg_set_cfs_period(struct task_group *tg, long cfs_period_us)
5171 + {
5172 + u64 quota, period;
5173 +
5174 ++ if ((u64)cfs_period_us > U64_MAX / NSEC_PER_USEC)
5175 ++ return -EINVAL;
5176 ++
5177 + period = (u64)cfs_period_us * NSEC_PER_USEC;
5178 + quota = tg->cfs_bandwidth.quota;
5179 +
5180 +diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
5181 +index cb9a5b8532fa..cc7dd1aaf08e 100644
5182 +--- a/kernel/sched/rt.c
5183 ++++ b/kernel/sched/rt.c
5184 +@@ -2533,6 +2533,8 @@ int sched_group_set_rt_runtime(struct task_group *tg, long rt_runtime_us)
5185 + rt_runtime = (u64)rt_runtime_us * NSEC_PER_USEC;
5186 + if (rt_runtime_us < 0)
5187 + rt_runtime = RUNTIME_INF;
5188 ++ else if ((u64)rt_runtime_us > U64_MAX / NSEC_PER_USEC)
5189 ++ return -EINVAL;
5190 +
5191 + return tg_set_rt_bandwidth(tg, rt_period, rt_runtime);
5192 + }
5193 +@@ -2553,6 +2555,9 @@ int sched_group_set_rt_period(struct task_group *tg, u64 rt_period_us)
5194 + {
5195 + u64 rt_runtime, rt_period;
5196 +
5197 ++ if (rt_period_us > U64_MAX / NSEC_PER_USEC)
5198 ++ return -EINVAL;
5199 ++
5200 + rt_period = rt_period_us * NSEC_PER_USEC;
5201 + rt_runtime = tg->rt_bandwidth.rt_runtime;
5202 +
5203 +diff --git a/kernel/trace/trace_branch.c b/kernel/trace/trace_branch.c
5204 +index 4ad967453b6f..3ea65cdff30d 100644
5205 +--- a/kernel/trace/trace_branch.c
5206 ++++ b/kernel/trace/trace_branch.c
5207 +@@ -205,6 +205,8 @@ void trace_likely_condition(struct ftrace_likely_data *f, int val, int expect)
5208 + void ftrace_likely_update(struct ftrace_likely_data *f, int val,
5209 + int expect, int is_constant)
5210 + {
5211 ++ unsigned long flags = user_access_save();
5212 ++
5213 + /* A constant is always correct */
5214 + if (is_constant) {
5215 + f->constant++;
5216 +@@ -223,6 +225,8 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
5217 + f->data.correct++;
5218 + else
5219 + f->data.incorrect++;
5220 ++
5221 ++ user_access_restore(flags);
5222 + }
5223 + EXPORT_SYMBOL(ftrace_likely_update);
5224 +
5225 +diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
5226 +index f237a09a5862..3916cf0e2f0a 100644
5227 +--- a/lib/kobject_uevent.c
5228 ++++ b/lib/kobject_uevent.c
5229 +@@ -340,6 +340,13 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
5230 + struct uevent_sock *ue_sk;
5231 + #endif
5232 +
5233 ++ /*
5234 ++ * Mark "remove" event done regardless of result, for some subsystems
5235 ++ * do not want to re-trigger "remove" event via automatic cleanup.
5236 ++ */
5237 ++ if (action == KOBJ_REMOVE)
5238 ++ kobj->state_remove_uevent_sent = 1;
5239 ++
5240 + pr_debug("kobject: '%s' (%p): %s\n",
5241 + kobject_name(kobj), kobj, __func__);
5242 +
5243 +@@ -441,10 +448,6 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
5244 + kobj->state_add_uevent_sent = 1;
5245 + break;
5246 +
5247 +- case KOBJ_REMOVE:
5248 +- kobj->state_remove_uevent_sent = 1;
5249 +- break;
5250 +-
5251 + case KOBJ_UNBIND:
5252 + zap_modalias_env(env);
5253 + break;
5254 +diff --git a/lib/sbitmap.c b/lib/sbitmap.c
5255 +index 80aa8d5463fa..8e467917e0d1 100644
5256 +--- a/lib/sbitmap.c
5257 ++++ b/lib/sbitmap.c
5258 +@@ -338,7 +338,7 @@ void sbitmap_queue_resize(struct sbitmap_queue *sbq, unsigned int depth)
5259 + * Pairs with the memory barrier in sbq_wake_up() to ensure that
5260 + * the batch size is updated before the wait counts.
5261 + */
5262 +- smp_mb__before_atomic();
5263 ++ smp_mb();
5264 + for (i = 0; i < SBQ_WAIT_QUEUES; i++)
5265 + atomic_set(&sbq->ws[i].wait_cnt, 1);
5266 + }
5267 +diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
5268 +index b53e1b5d80f4..e304b54c9c7d 100644
5269 +--- a/lib/strncpy_from_user.c
5270 ++++ b/lib/strncpy_from_user.c
5271 +@@ -23,10 +23,11 @@
5272 + * hit it), 'max' is the address space maximum (and we return
5273 + * -EFAULT if we hit it).
5274 + */
5275 +-static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
5276 ++static inline long do_strncpy_from_user(char *dst, const char __user *src,
5277 ++ unsigned long count, unsigned long max)
5278 + {
5279 + const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
5280 +- long res = 0;
5281 ++ unsigned long res = 0;
5282 +
5283 + /*
5284 + * Truncate 'max' to the user-specified limit, so that
5285 +diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
5286 +index 60d0bbda8f5e..184f80f7bacf 100644
5287 +--- a/lib/strnlen_user.c
5288 ++++ b/lib/strnlen_user.c
5289 +@@ -28,7 +28,7 @@
5290 + static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
5291 + {
5292 + const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
5293 +- long align, res = 0;
5294 ++ unsigned long align, res = 0;
5295 + unsigned long c;
5296 +
5297 + /*
5298 +@@ -42,7 +42,7 @@ static inline long do_strnlen_user(const char __user *src, unsigned long count,
5299 + * Do everything aligned. But that means that we
5300 + * need to also expand the maximum..
5301 + */
5302 +- align = (sizeof(long) - 1) & (unsigned long)src;
5303 ++ align = (sizeof(unsigned long) - 1) & (unsigned long)src;
5304 + src -= align;
5305 + max += align;
5306 +
5307 +diff --git a/mm/hugetlb.c b/mm/hugetlb.c
5308 +index 64a62584290c..741bdde54954 100644
5309 +--- a/mm/hugetlb.c
5310 ++++ b/mm/hugetlb.c
5311 +@@ -3729,8 +3729,8 @@ retry:
5312 + * handling userfault. Reacquire after handling
5313 + * fault to make calling code simpler.
5314 + */
5315 +- hash = hugetlb_fault_mutex_hash(h, mm, vma, mapping,
5316 +- idx, address);
5317 ++ hash = hugetlb_fault_mutex_hash(h, mapping, idx,
5318 ++ address);
5319 + mutex_unlock(&hugetlb_fault_mutex_table[hash]);
5320 + ret = handle_userfault(&vmf, VM_UFFD_MISSING);
5321 + mutex_lock(&hugetlb_fault_mutex_table[hash]);
5322 +@@ -3842,21 +3842,14 @@ backout_unlocked:
5323 + }
5324 +
5325 + #ifdef CONFIG_SMP
5326 +-u32 hugetlb_fault_mutex_hash(struct hstate *h, struct mm_struct *mm,
5327 +- struct vm_area_struct *vma,
5328 +- struct address_space *mapping,
5329 ++u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping,
5330 + pgoff_t idx, unsigned long address)
5331 + {
5332 + unsigned long key[2];
5333 + u32 hash;
5334 +
5335 +- if (vma->vm_flags & VM_SHARED) {
5336 +- key[0] = (unsigned long) mapping;
5337 +- key[1] = idx;
5338 +- } else {
5339 +- key[0] = (unsigned long) mm;
5340 +- key[1] = address >> huge_page_shift(h);
5341 +- }
5342 ++ key[0] = (unsigned long) mapping;
5343 ++ key[1] = idx;
5344 +
5345 + hash = jhash2((u32 *)&key, sizeof(key)/sizeof(u32), 0);
5346 +
5347 +@@ -3867,9 +3860,7 @@ u32 hugetlb_fault_mutex_hash(struct hstate *h, struct mm_struct *mm,
5348 + * For uniprocesor systems we always use a single mutex, so just
5349 + * return 0 and avoid the hashing overhead.
5350 + */
5351 +-u32 hugetlb_fault_mutex_hash(struct hstate *h, struct mm_struct *mm,
5352 +- struct vm_area_struct *vma,
5353 +- struct address_space *mapping,
5354 ++u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping,
5355 + pgoff_t idx, unsigned long address)
5356 + {
5357 + return 0;
5358 +@@ -3915,7 +3906,7 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
5359 + * get spurious allocation failures if two CPUs race to instantiate
5360 + * the same page in the page cache.
5361 + */
5362 +- hash = hugetlb_fault_mutex_hash(h, mm, vma, mapping, idx, address);
5363 ++ hash = hugetlb_fault_mutex_hash(h, mapping, idx, address);
5364 + mutex_lock(&hugetlb_fault_mutex_table[hash]);
5365 +
5366 + entry = huge_ptep_get(ptep);
5367 +diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
5368 +index 5d70fdbd8bc0..d3b4a78d79b6 100644
5369 +--- a/mm/userfaultfd.c
5370 ++++ b/mm/userfaultfd.c
5371 +@@ -272,8 +272,7 @@ retry:
5372 + */
5373 + idx = linear_page_index(dst_vma, dst_addr);
5374 + mapping = dst_vma->vm_file->f_mapping;
5375 +- hash = hugetlb_fault_mutex_hash(h, dst_mm, dst_vma, mapping,
5376 +- idx, dst_addr);
5377 ++ hash = hugetlb_fault_mutex_hash(h, mapping, idx, dst_addr);
5378 + mutex_lock(&hugetlb_fault_mutex_table[hash]);
5379 +
5380 + err = -ENOMEM;
5381 +diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
5382 +index 4f0111bc6621..8d1d0fdb157e 100644
5383 +--- a/net/batman-adv/distributed-arp-table.c
5384 ++++ b/net/batman-adv/distributed-arp-table.c
5385 +@@ -1240,7 +1240,6 @@ bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
5386 + hw_src, &ip_src, hw_dst, &ip_dst,
5387 + dat_entry->mac_addr, &dat_entry->ip);
5388 + dropped = true;
5389 +- goto out;
5390 + }
5391 +
5392 + /* Update our internal cache with both the IP addresses the node got
5393 +@@ -1249,6 +1248,9 @@ bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
5394 + batadv_dat_entry_add(bat_priv, ip_src, hw_src, vid);
5395 + batadv_dat_entry_add(bat_priv, ip_dst, hw_dst, vid);
5396 +
5397 ++ if (dropped)
5398 ++ goto out;
5399 ++
5400 + /* If BLA is enabled, only forward ARP replies if we have claimed the
5401 + * source of the ARP reply or if no one else of the same backbone has
5402 + * already claimed that client. This prevents that different gateways
5403 +diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
5404 +index fb381fb26a66..5762e52f1d1f 100644
5405 +--- a/net/batman-adv/main.c
5406 ++++ b/net/batman-adv/main.c
5407 +@@ -153,6 +153,7 @@ int batadv_mesh_init(struct net_device *soft_iface)
5408 + spin_lock_init(&bat_priv->tt.commit_lock);
5409 + spin_lock_init(&bat_priv->gw.list_lock);
5410 + #ifdef CONFIG_BATMAN_ADV_MCAST
5411 ++ spin_lock_init(&bat_priv->mcast.mla_lock);
5412 + spin_lock_init(&bat_priv->mcast.want_lists_lock);
5413 + #endif
5414 + spin_lock_init(&bat_priv->tvlv.container_list_lock);
5415 +diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
5416 +index fa02fb73367c..d47865e0e697 100644
5417 +--- a/net/batman-adv/multicast.c
5418 ++++ b/net/batman-adv/multicast.c
5419 +@@ -269,8 +269,6 @@ static void batadv_mcast_mla_list_free(struct hlist_head *mcast_list)
5420 + * translation table except the ones listed in the given mcast_list.
5421 + *
5422 + * If mcast_list is NULL then all are retracted.
5423 +- *
5424 +- * Do not call outside of the mcast worker! (or cancel mcast worker first)
5425 + */
5426 + static void batadv_mcast_mla_tt_retract(struct batadv_priv *bat_priv,
5427 + struct hlist_head *mcast_list)
5428 +@@ -278,8 +276,6 @@ static void batadv_mcast_mla_tt_retract(struct batadv_priv *bat_priv,
5429 + struct batadv_hw_addr *mcast_entry;
5430 + struct hlist_node *tmp;
5431 +
5432 +- WARN_ON(delayed_work_pending(&bat_priv->mcast.work));
5433 +-
5434 + hlist_for_each_entry_safe(mcast_entry, tmp, &bat_priv->mcast.mla_list,
5435 + list) {
5436 + if (mcast_list &&
5437 +@@ -303,8 +299,6 @@ static void batadv_mcast_mla_tt_retract(struct batadv_priv *bat_priv,
5438 + *
5439 + * Adds multicast listener announcements from the given mcast_list to the
5440 + * translation table if they have not been added yet.
5441 +- *
5442 +- * Do not call outside of the mcast worker! (or cancel mcast worker first)
5443 + */
5444 + static void batadv_mcast_mla_tt_add(struct batadv_priv *bat_priv,
5445 + struct hlist_head *mcast_list)
5446 +@@ -312,8 +306,6 @@ static void batadv_mcast_mla_tt_add(struct batadv_priv *bat_priv,
5447 + struct batadv_hw_addr *mcast_entry;
5448 + struct hlist_node *tmp;
5449 +
5450 +- WARN_ON(delayed_work_pending(&bat_priv->mcast.work));
5451 +-
5452 + if (!mcast_list)
5453 + return;
5454 +
5455 +@@ -600,7 +592,10 @@ static void batadv_mcast_mla_update(struct work_struct *work)
5456 + priv_mcast = container_of(delayed_work, struct batadv_priv_mcast, work);
5457 + bat_priv = container_of(priv_mcast, struct batadv_priv, mcast);
5458 +
5459 ++ spin_lock(&bat_priv->mcast.mla_lock);
5460 + __batadv_mcast_mla_update(bat_priv);
5461 ++ spin_unlock(&bat_priv->mcast.mla_lock);
5462 ++
5463 + batadv_mcast_start_timer(bat_priv);
5464 + }
5465 +
5466 +diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
5467 +index a62795868794..d5e3968619b8 100644
5468 +--- a/net/batman-adv/types.h
5469 ++++ b/net/batman-adv/types.h
5470 +@@ -798,6 +798,7 @@ struct batadv_mcast_querier_state {
5471 + * @flags: the flags we have last sent in our mcast tvlv
5472 + * @enabled: whether the multicast tvlv is currently enabled
5473 + * @bridged: whether the soft interface has a bridge on top
5474 ++ * @mla_lock: a lock protecting mla_list and mla_flags
5475 + * @num_disabled: number of nodes that have no mcast tvlv
5476 + * @num_want_all_unsnoopables: number of nodes wanting unsnoopable IP traffic
5477 + * @num_want_all_ipv4: counter for items in want_all_ipv4_list
5478 +@@ -816,6 +817,7 @@ struct batadv_priv_mcast {
5479 + u8 flags;
5480 + bool enabled;
5481 + bool bridged;
5482 ++ spinlock_t mla_lock;
5483 + atomic_t num_disabled;
5484 + atomic_t num_want_all_unsnoopables;
5485 + atomic_t num_want_all_ipv4;
5486 +diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
5487 +index dd3bcf22fe8b..0fc499db6da2 100644
5488 +--- a/net/ipv4/ip_gre.c
5489 ++++ b/net/ipv4/ip_gre.c
5490 +@@ -689,7 +689,7 @@ static void erspan_build_header(struct sk_buff *skb,
5491 + __be32 id, u32 index, bool truncate)
5492 + {
5493 + struct iphdr *iphdr = ip_hdr(skb);
5494 +- struct ethhdr *eth = eth_hdr(skb);
5495 ++ struct ethhdr *eth = (struct ethhdr *)skb->data;
5496 + enum erspan_encap_type enc_type;
5497 + struct erspanhdr *ershdr;
5498 + struct qtag_prefix {
5499 +diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
5500 +index 4c59b5507e7a..33bd6da00a1c 100644
5501 +--- a/net/mac80211/mlme.c
5502 ++++ b/net/mac80211/mlme.c
5503 +@@ -1071,9 +1071,6 @@ static void ieee80211_chswitch_work(struct work_struct *work)
5504 + goto out;
5505 + }
5506 +
5507 +- /* XXX: shouldn't really modify cfg80211-owned data! */
5508 +- ifmgd->associated->channel = sdata->csa_chandef.chan;
5509 +-
5510 + ifmgd->csa_waiting_bcn = true;
5511 +
5512 + ieee80211_sta_reset_beacon_monitor(sdata);
5513 +diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
5514 +index c1a2ad050e61..c672a790df1c 100644
5515 +--- a/net/wireless/nl80211.c
5516 ++++ b/net/wireless/nl80211.c
5517 +@@ -14706,6 +14706,11 @@ void cfg80211_ch_switch_notify(struct net_device *dev,
5518 +
5519 + wdev->chandef = *chandef;
5520 + wdev->preset_chandef = *chandef;
5521 ++
5522 ++ if (wdev->iftype == NL80211_IFTYPE_STATION &&
5523 ++ !WARN_ON(!wdev->current_bss))
5524 ++ wdev->current_bss->pub.channel = chandef->chan;
5525 ++
5526 + nl80211_ch_switch_notify(rdev, dev, chandef, GFP_KERNEL,
5527 + NL80211_CMD_CH_SWITCH_NOTIFY, 0);
5528 + }
5529 +diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
5530 +index 7406695ee5dc..e00f5f49f21d 100644
5531 +--- a/sound/soc/codecs/hdmi-codec.c
5532 ++++ b/sound/soc/codecs/hdmi-codec.c
5533 +@@ -446,8 +446,12 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream,
5534 + if (!ret) {
5535 + ret = snd_pcm_hw_constraint_eld(substream->runtime,
5536 + hcp->eld);
5537 +- if (ret)
5538 ++ if (ret) {
5539 ++ mutex_lock(&hcp->current_stream_lock);
5540 ++ hcp->current_stream = NULL;
5541 ++ mutex_unlock(&hcp->current_stream_lock);
5542 + return ret;
5543 ++ }
5544 + }
5545 + /* Select chmap supported */
5546 + hdmi_codec_eld_chmap(hcp);
5547 +diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
5548 +index f395bbc7c354..9aa741d27279 100644
5549 +--- a/sound/soc/davinci/davinci-mcasp.c
5550 ++++ b/sound/soc/davinci/davinci-mcasp.c
5551 +@@ -43,6 +43,7 @@
5552 +
5553 + #define MCASP_MAX_AFIFO_DEPTH 64
5554 +
5555 ++#ifdef CONFIG_PM
5556 + static u32 context_regs[] = {
5557 + DAVINCI_MCASP_TXFMCTL_REG,
5558 + DAVINCI_MCASP_RXFMCTL_REG,
5559 +@@ -65,6 +66,7 @@ struct davinci_mcasp_context {
5560 + u32 *xrsr_regs; /* for serializer configuration */
5561 + bool pm_state;
5562 + };
5563 ++#endif
5564 +
5565 + struct davinci_mcasp_ruledata {
5566 + struct davinci_mcasp *mcasp;
5567 +diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
5568 +index 4087deeda7cf..2523b0065990 100644
5569 +--- a/sound/soc/fsl/Kconfig
5570 ++++ b/sound/soc/fsl/Kconfig
5571 +@@ -173,16 +173,17 @@ config SND_MPC52xx_SOC_EFIKA
5572 +
5573 + endif # SND_POWERPC_SOC
5574 +
5575 ++config SND_SOC_IMX_PCM_FIQ
5576 ++ tristate
5577 ++ default y if SND_SOC_IMX_SSI=y && (SND_SOC_FSL_SSI=m || SND_SOC_FSL_SPDIF=m) && (MXC_TZIC || MXC_AVIC)
5578 ++ select FIQ
5579 ++
5580 + if SND_IMX_SOC
5581 +
5582 + config SND_SOC_IMX_SSI
5583 + tristate
5584 + select SND_SOC_FSL_UTILS
5585 +
5586 +-config SND_SOC_IMX_PCM_FIQ
5587 +- tristate
5588 +- select FIQ
5589 +-
5590 + comment "SoC Audio support for Freescale i.MX boards:"
5591 +
5592 + config SND_MXC_SOC_WM1133_EV1
5593 +diff --git a/sound/soc/fsl/eukrea-tlv320.c b/sound/soc/fsl/eukrea-tlv320.c
5594 +index 84ef6385736c..4c6f19ef98b2 100644
5595 +--- a/sound/soc/fsl/eukrea-tlv320.c
5596 ++++ b/sound/soc/fsl/eukrea-tlv320.c
5597 +@@ -119,13 +119,13 @@ static int eukrea_tlv320_probe(struct platform_device *pdev)
5598 + if (ret) {
5599 + dev_err(&pdev->dev,
5600 + "fsl,mux-int-port node missing or invalid.\n");
5601 +- return ret;
5602 ++ goto err;
5603 + }
5604 + ret = of_property_read_u32(np, "fsl,mux-ext-port", &ext_port);
5605 + if (ret) {
5606 + dev_err(&pdev->dev,
5607 + "fsl,mux-ext-port node missing or invalid.\n");
5608 +- return ret;
5609 ++ goto err;
5610 + }
5611 +
5612 + /*
5613 +diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
5614 +index 18e5ce81527d..c1c733b573a7 100644
5615 +--- a/sound/soc/fsl/fsl_sai.c
5616 ++++ b/sound/soc/fsl/fsl_sai.c
5617 +@@ -274,12 +274,14 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai,
5618 + case SND_SOC_DAIFMT_CBS_CFS:
5619 + val_cr2 |= FSL_SAI_CR2_BCD_MSTR;
5620 + val_cr4 |= FSL_SAI_CR4_FSD_MSTR;
5621 ++ sai->is_slave_mode = false;
5622 + break;
5623 + case SND_SOC_DAIFMT_CBM_CFM:
5624 + sai->is_slave_mode = true;
5625 + break;
5626 + case SND_SOC_DAIFMT_CBS_CFM:
5627 + val_cr2 |= FSL_SAI_CR2_BCD_MSTR;
5628 ++ sai->is_slave_mode = false;
5629 + break;
5630 + case SND_SOC_DAIFMT_CBM_CFS:
5631 + val_cr4 |= FSL_SAI_CR4_FSD_MSTR;
5632 +diff --git a/sound/soc/fsl/fsl_utils.c b/sound/soc/fsl/fsl_utils.c
5633 +index b9e42b503a37..4f8bdb7650e8 100644
5634 +--- a/sound/soc/fsl/fsl_utils.c
5635 ++++ b/sound/soc/fsl/fsl_utils.c
5636 +@@ -75,6 +75,7 @@ int fsl_asoc_get_dma_channel(struct device_node *ssi_np,
5637 + iprop = of_get_property(dma_np, "cell-index", NULL);
5638 + if (!iprop) {
5639 + of_node_put(dma_np);
5640 ++ of_node_put(dma_channel_np);
5641 + return -EINVAL;
5642 + }
5643 + *dma_id = be32_to_cpup(iprop);
5644 +diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
5645 +index 1d6907d379c9..976b28137d83 100644
5646 +--- a/tools/lib/bpf/bpf.c
5647 ++++ b/tools/lib/bpf/bpf.c
5648 +@@ -41,6 +41,8 @@
5649 + # define __NR_bpf 349
5650 + # elif defined(__s390__)
5651 + # define __NR_bpf 351
5652 ++# elif defined(__arc__)
5653 ++# define __NR_bpf 280
5654 + # else
5655 + # error __NR_bpf not defined. libbpf does not support your arch.
5656 + # endif
5657 +diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h
5658 +index b8ea5843c39e..e9423d6af933 100644
5659 +--- a/tools/lib/bpf/bpf.h
5660 ++++ b/tools/lib/bpf/bpf.h
5661 +@@ -23,6 +23,7 @@
5662 +
5663 + #include <linux/bpf.h>
5664 + #include <stddef.h>
5665 ++#include <stdint.h>
5666 +
5667 + int bpf_create_map_node(enum bpf_map_type map_type, int key_size,
5668 + int value_size, int max_entries, __u32 map_flags,