Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:5.10 commit in: /
Date: Tue, 02 Nov 2021 19:31:03
Message-Id: 1635881447.9cf8f89abc05df38155620672159e91f8c2321f3.mpagano@gentoo
1 commit: 9cf8f89abc05df38155620672159e91f8c2321f3
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Tue Nov 2 19:30:47 2021 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Tue Nov 2 19:30:47 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=9cf8f89a
7
8 Linux patch 5.10.77
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1076_linux-5.10.77.patch | 3073 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 3077 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 16f8398..40e234a 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -347,6 +347,10 @@ Patch: 1075_linux-5.10.76.patch
21 From: http://www.kernel.org
22 Desc: Linux 5.10.76
23
24 +Patch: 1076_linux-5.10.77.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 5.10.77
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/1076_linux-5.10.77.patch b/1076_linux-5.10.77.patch
33 new file mode 100644
34 index 0000000..d168d15
35 --- /dev/null
36 +++ b/1076_linux-5.10.77.patch
37 @@ -0,0 +1,3073 @@
38 +diff --git a/Makefile b/Makefile
39 +index 605bd943b224e..a58f49e415dc6 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,7 +1,7 @@
43 + # SPDX-License-Identifier: GPL-2.0
44 + VERSION = 5
45 + PATCHLEVEL = 10
46 +-SUBLEVEL = 76
47 ++SUBLEVEL = 77
48 + EXTRAVERSION =
49 + NAME = Dare mighty things
50 +
51 +diff --git a/arch/arm/boot/compressed/decompress.c b/arch/arm/boot/compressed/decompress.c
52 +index aa075d8372ea2..74255e8198314 100644
53 +--- a/arch/arm/boot/compressed/decompress.c
54 ++++ b/arch/arm/boot/compressed/decompress.c
55 +@@ -47,7 +47,10 @@ extern char * strchrnul(const char *, int);
56 + #endif
57 +
58 + #ifdef CONFIG_KERNEL_XZ
59 ++/* Prevent KASAN override of string helpers in decompressor */
60 ++#undef memmove
61 + #define memmove memmove
62 ++#undef memcpy
63 + #define memcpy memcpy
64 + #include "../../../../lib/decompress_unxz.c"
65 + #endif
66 +diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
67 +index a13d902064722..d9db752c51fe2 100644
68 +--- a/arch/arm/include/asm/uaccess.h
69 ++++ b/arch/arm/include/asm/uaccess.h
70 +@@ -200,6 +200,7 @@ extern int __get_user_64t_4(void *);
71 + register unsigned long __l asm("r1") = __limit; \
72 + register int __e asm("r0"); \
73 + unsigned int __ua_flags = uaccess_save_and_enable(); \
74 ++ int __tmp_e; \
75 + switch (sizeof(*(__p))) { \
76 + case 1: \
77 + if (sizeof((x)) >= 8) \
78 +@@ -227,9 +228,10 @@ extern int __get_user_64t_4(void *);
79 + break; \
80 + default: __e = __get_user_bad(); break; \
81 + } \
82 ++ __tmp_e = __e; \
83 + uaccess_restore(__ua_flags); \
84 + x = (typeof(*(p))) __r2; \
85 +- __e; \
86 ++ __tmp_e; \
87 + })
88 +
89 + #define get_user(x, p) \
90 +diff --git a/arch/arm/kernel/vmlinux-xip.lds.S b/arch/arm/kernel/vmlinux-xip.lds.S
91 +index 50136828f5b54..f14c2360ea0b1 100644
92 +--- a/arch/arm/kernel/vmlinux-xip.lds.S
93 ++++ b/arch/arm/kernel/vmlinux-xip.lds.S
94 +@@ -40,6 +40,10 @@ SECTIONS
95 + ARM_DISCARD
96 + *(.alt.smp.init)
97 + *(.pv_table)
98 ++#ifndef CONFIG_ARM_UNWIND
99 ++ *(.ARM.exidx) *(.ARM.exidx.*)
100 ++ *(.ARM.extab) *(.ARM.extab.*)
101 ++#endif
102 + }
103 +
104 + . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR);
105 +@@ -172,7 +176,7 @@ ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")
106 + ASSERT((_end - __bss_start) >= 12288, ".bss too small for CONFIG_XIP_DEFLATED_DATA")
107 + #endif
108 +
109 +-#ifdef CONFIG_ARM_MPU
110 ++#if defined(CONFIG_ARM_MPU) && !defined(CONFIG_COMPILE_TEST)
111 + /*
112 + * Due to PMSAv7 restriction on base address and size we have to
113 + * enforce minimal alignment restrictions. It was seen that weaker
114 +diff --git a/arch/arm/mm/proc-macros.S b/arch/arm/mm/proc-macros.S
115 +index e2c743aa2eb2b..d9f7dfe2a7ed3 100644
116 +--- a/arch/arm/mm/proc-macros.S
117 ++++ b/arch/arm/mm/proc-macros.S
118 +@@ -340,6 +340,7 @@ ENTRY(\name\()_cache_fns)
119 +
120 + .macro define_tlb_functions name:req, flags_up:req, flags_smp
121 + .type \name\()_tlb_fns, #object
122 ++ .align 2
123 + ENTRY(\name\()_tlb_fns)
124 + .long \name\()_flush_user_tlb_range
125 + .long \name\()_flush_kern_tlb_range
126 +diff --git a/arch/arm/probes/kprobes/core.c b/arch/arm/probes/kprobes/core.c
127 +index a9653117ca0dd..e513d8a467760 100644
128 +--- a/arch/arm/probes/kprobes/core.c
129 ++++ b/arch/arm/probes/kprobes/core.c
130 +@@ -462,7 +462,7 @@ static struct undef_hook kprobes_arm_break_hook = {
131 +
132 + #endif /* !CONFIG_THUMB2_KERNEL */
133 +
134 +-int __init arch_init_kprobes()
135 ++int __init arch_init_kprobes(void)
136 + {
137 + arm_probes_decode_init();
138 + #ifdef CONFIG_THUMB2_KERNEL
139 +diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-neo2.dts b/arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-neo2.dts
140 +index b059e20813bdf..e8ab8c2df51a0 100644
141 +--- a/arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-neo2.dts
142 ++++ b/arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-neo2.dts
143 +@@ -75,7 +75,7 @@
144 + pinctrl-0 = <&emac_rgmii_pins>;
145 + phy-supply = <&reg_gmac_3v3>;
146 + phy-handle = <&ext_rgmii_phy>;
147 +- phy-mode = "rgmii";
148 ++ phy-mode = "rgmii-id";
149 + status = "okay";
150 + };
151 +
152 +diff --git a/arch/arm64/lib/copy_from_user.S b/arch/arm64/lib/copy_from_user.S
153 +index 0f8a3a9e3795b..957a6d092d7af 100644
154 +--- a/arch/arm64/lib/copy_from_user.S
155 ++++ b/arch/arm64/lib/copy_from_user.S
156 +@@ -29,7 +29,7 @@
157 + .endm
158 +
159 + .macro ldrh1 reg, ptr, val
160 +- uao_user_alternative 9998f, ldrh, ldtrh, \reg, \ptr, \val
161 ++ uao_user_alternative 9997f, ldrh, ldtrh, \reg, \ptr, \val
162 + .endm
163 +
164 + .macro strh1 reg, ptr, val
165 +@@ -37,7 +37,7 @@
166 + .endm
167 +
168 + .macro ldr1 reg, ptr, val
169 +- uao_user_alternative 9998f, ldr, ldtr, \reg, \ptr, \val
170 ++ uao_user_alternative 9997f, ldr, ldtr, \reg, \ptr, \val
171 + .endm
172 +
173 + .macro str1 reg, ptr, val
174 +@@ -45,7 +45,7 @@
175 + .endm
176 +
177 + .macro ldp1 reg1, reg2, ptr, val
178 +- uao_ldp 9998f, \reg1, \reg2, \ptr, \val
179 ++ uao_ldp 9997f, \reg1, \reg2, \ptr, \val
180 + .endm
181 +
182 + .macro stp1 reg1, reg2, ptr, val
183 +@@ -53,8 +53,10 @@
184 + .endm
185 +
186 + end .req x5
187 ++srcin .req x15
188 + SYM_FUNC_START(__arch_copy_from_user)
189 + add end, x0, x2
190 ++ mov srcin, x1
191 + #include "copy_template.S"
192 + mov x0, #0 // Nothing to copy
193 + ret
194 +@@ -63,6 +65,11 @@ EXPORT_SYMBOL(__arch_copy_from_user)
195 +
196 + .section .fixup,"ax"
197 + .align 2
198 ++9997: cmp dst, dstin
199 ++ b.ne 9998f
200 ++ // Before being absolutely sure we couldn't copy anything, try harder
201 ++USER(9998f, ldtrb tmp1w, [srcin])
202 ++ strb tmp1w, [dst], #1
203 + 9998: sub x0, end, dst // bytes not copied
204 + ret
205 + .previous
206 +diff --git a/arch/arm64/lib/copy_in_user.S b/arch/arm64/lib/copy_in_user.S
207 +index 80e37ada0ee1a..35c01da09323e 100644
208 +--- a/arch/arm64/lib/copy_in_user.S
209 ++++ b/arch/arm64/lib/copy_in_user.S
210 +@@ -30,33 +30,34 @@
211 + .endm
212 +
213 + .macro ldrh1 reg, ptr, val
214 +- uao_user_alternative 9998f, ldrh, ldtrh, \reg, \ptr, \val
215 ++ uao_user_alternative 9997f, ldrh, ldtrh, \reg, \ptr, \val
216 + .endm
217 +
218 + .macro strh1 reg, ptr, val
219 +- uao_user_alternative 9998f, strh, sttrh, \reg, \ptr, \val
220 ++ uao_user_alternative 9997f, strh, sttrh, \reg, \ptr, \val
221 + .endm
222 +
223 + .macro ldr1 reg, ptr, val
224 +- uao_user_alternative 9998f, ldr, ldtr, \reg, \ptr, \val
225 ++ uao_user_alternative 9997f, ldr, ldtr, \reg, \ptr, \val
226 + .endm
227 +
228 + .macro str1 reg, ptr, val
229 +- uao_user_alternative 9998f, str, sttr, \reg, \ptr, \val
230 ++ uao_user_alternative 9997f, str, sttr, \reg, \ptr, \val
231 + .endm
232 +
233 + .macro ldp1 reg1, reg2, ptr, val
234 +- uao_ldp 9998f, \reg1, \reg2, \ptr, \val
235 ++ uao_ldp 9997f, \reg1, \reg2, \ptr, \val
236 + .endm
237 +
238 + .macro stp1 reg1, reg2, ptr, val
239 +- uao_stp 9998f, \reg1, \reg2, \ptr, \val
240 ++ uao_stp 9997f, \reg1, \reg2, \ptr, \val
241 + .endm
242 +
243 + end .req x5
244 +-
245 ++srcin .req x15
246 + SYM_FUNC_START(__arch_copy_in_user)
247 + add end, x0, x2
248 ++ mov srcin, x1
249 + #include "copy_template.S"
250 + mov x0, #0
251 + ret
252 +@@ -65,6 +66,12 @@ EXPORT_SYMBOL(__arch_copy_in_user)
253 +
254 + .section .fixup,"ax"
255 + .align 2
256 ++9997: cmp dst, dstin
257 ++ b.ne 9998f
258 ++ // Before being absolutely sure we couldn't copy anything, try harder
259 ++USER(9998f, ldtrb tmp1w, [srcin])
260 ++USER(9998f, sttrb tmp1w, [dst])
261 ++ add dst, dst, #1
262 + 9998: sub x0, end, dst // bytes not copied
263 + ret
264 + .previous
265 +diff --git a/arch/arm64/lib/copy_to_user.S b/arch/arm64/lib/copy_to_user.S
266 +index 4ec59704b8f2d..85705350ff354 100644
267 +--- a/arch/arm64/lib/copy_to_user.S
268 ++++ b/arch/arm64/lib/copy_to_user.S
269 +@@ -32,7 +32,7 @@
270 + .endm
271 +
272 + .macro strh1 reg, ptr, val
273 +- uao_user_alternative 9998f, strh, sttrh, \reg, \ptr, \val
274 ++ uao_user_alternative 9997f, strh, sttrh, \reg, \ptr, \val
275 + .endm
276 +
277 + .macro ldr1 reg, ptr, val
278 +@@ -40,7 +40,7 @@
279 + .endm
280 +
281 + .macro str1 reg, ptr, val
282 +- uao_user_alternative 9998f, str, sttr, \reg, \ptr, \val
283 ++ uao_user_alternative 9997f, str, sttr, \reg, \ptr, \val
284 + .endm
285 +
286 + .macro ldp1 reg1, reg2, ptr, val
287 +@@ -48,12 +48,14 @@
288 + .endm
289 +
290 + .macro stp1 reg1, reg2, ptr, val
291 +- uao_stp 9998f, \reg1, \reg2, \ptr, \val
292 ++ uao_stp 9997f, \reg1, \reg2, \ptr, \val
293 + .endm
294 +
295 + end .req x5
296 ++srcin .req x15
297 + SYM_FUNC_START(__arch_copy_to_user)
298 + add end, x0, x2
299 ++ mov srcin, x1
300 + #include "copy_template.S"
301 + mov x0, #0
302 + ret
303 +@@ -62,6 +64,12 @@ EXPORT_SYMBOL(__arch_copy_to_user)
304 +
305 + .section .fixup,"ax"
306 + .align 2
307 ++9997: cmp dst, dstin
308 ++ b.ne 9998f
309 ++ // Before being absolutely sure we couldn't copy anything, try harder
310 ++ ldrb tmp1w, [srcin]
311 ++USER(9998f, sttrb tmp1w, [dst])
312 ++ add dst, dst, #1
313 + 9998: sub x0, end, dst // bytes not copied
314 + ret
315 + .previous
316 +diff --git a/arch/nios2/platform/Kconfig.platform b/arch/nios2/platform/Kconfig.platform
317 +index 9e32fb7f3d4ce..e849daff6fd16 100644
318 +--- a/arch/nios2/platform/Kconfig.platform
319 ++++ b/arch/nios2/platform/Kconfig.platform
320 +@@ -37,6 +37,7 @@ config NIOS2_DTB_PHYS_ADDR
321 +
322 + config NIOS2_DTB_SOURCE_BOOL
323 + bool "Compile and link device tree into kernel image"
324 ++ depends on !COMPILE_TEST
325 + help
326 + This allows you to specify a dts (device tree source) file
327 + which will be compiled and linked into the kernel image.
328 +diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
329 +index 0752967f351bb..a2750d6ffd0f5 100644
330 +--- a/arch/powerpc/net/bpf_jit_comp64.c
331 ++++ b/arch/powerpc/net/bpf_jit_comp64.c
332 +@@ -415,8 +415,14 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,
333 + case BPF_ALU64 | BPF_DIV | BPF_K: /* dst /= imm */
334 + if (imm == 0)
335 + return -EINVAL;
336 +- else if (imm == 1)
337 +- goto bpf_alu32_trunc;
338 ++ if (imm == 1) {
339 ++ if (BPF_OP(code) == BPF_DIV) {
340 ++ goto bpf_alu32_trunc;
341 ++ } else {
342 ++ EMIT(PPC_RAW_LI(dst_reg, 0));
343 ++ break;
344 ++ }
345 ++ }
346 +
347 + PPC_LI32(b2p[TMP_REG_1], imm);
348 + switch (BPF_CLASS(code)) {
349 +diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
350 +index f7abd118d23d3..1b894c3275781 100644
351 +--- a/arch/riscv/Kconfig
352 ++++ b/arch/riscv/Kconfig
353 +@@ -138,6 +138,12 @@ config PAGE_OFFSET
354 + default 0xffffffff80000000 if 64BIT && MAXPHYSMEM_2GB
355 + default 0xffffffe000000000 if 64BIT && MAXPHYSMEM_128GB
356 +
357 ++config KASAN_SHADOW_OFFSET
358 ++ hex
359 ++ depends on KASAN_GENERIC
360 ++ default 0xdfffffc800000000 if 64BIT
361 ++ default 0xffffffff if 32BIT
362 ++
363 + config ARCH_FLATMEM_ENABLE
364 + def_bool y
365 +
366 +diff --git a/arch/riscv/include/asm/kasan.h b/arch/riscv/include/asm/kasan.h
367 +index b04028c6218c9..db10a64e3b981 100644
368 +--- a/arch/riscv/include/asm/kasan.h
369 ++++ b/arch/riscv/include/asm/kasan.h
370 +@@ -14,8 +14,7 @@
371 + #define KASAN_SHADOW_START KERN_VIRT_START /* 2^64 - 2^38 */
372 + #define KASAN_SHADOW_END (KASAN_SHADOW_START + KASAN_SHADOW_SIZE)
373 +
374 +-#define KASAN_SHADOW_OFFSET (KASAN_SHADOW_END - (1ULL << \
375 +- (64 - KASAN_SHADOW_SCALE_SHIFT)))
376 ++#define KASAN_SHADOW_OFFSET _AC(CONFIG_KASAN_SHADOW_OFFSET, UL)
377 +
378 + void kasan_init(void);
379 + asmlinkage void kasan_early_init(void);
380 +diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S
381 +index 7e849797c9c38..1a819c18bedec 100644
382 +--- a/arch/riscv/kernel/head.S
383 ++++ b/arch/riscv/kernel/head.S
384 +@@ -175,6 +175,7 @@ setup_trap_vector:
385 + csrw CSR_SCRATCH, zero
386 + ret
387 +
388 ++.align 2
389 + .Lsecondary_park:
390 + /* We lack SMP support or have too many harts, so park this hart */
391 + wfi
392 +diff --git a/arch/riscv/mm/kasan_init.c b/arch/riscv/mm/kasan_init.c
393 +index a8a2ffd9114aa..883c3be43ea98 100644
394 +--- a/arch/riscv/mm/kasan_init.c
395 ++++ b/arch/riscv/mm/kasan_init.c
396 +@@ -16,6 +16,9 @@ asmlinkage void __init kasan_early_init(void)
397 + uintptr_t i;
398 + pgd_t *pgd = early_pg_dir + pgd_index(KASAN_SHADOW_START);
399 +
400 ++ BUILD_BUG_ON(KASAN_SHADOW_OFFSET !=
401 ++ KASAN_SHADOW_END - (1UL << (64 - KASAN_SHADOW_SCALE_SHIFT)));
402 ++
403 + for (i = 0; i < PTRS_PER_PTE; ++i)
404 + set_pte(kasan_early_shadow_pte + i,
405 + mk_pte(virt_to_page(kasan_early_shadow_page),
406 +diff --git a/arch/riscv/net/bpf_jit_core.c b/arch/riscv/net/bpf_jit_core.c
407 +index 3630d447352c6..cbf7d2414886e 100644
408 +--- a/arch/riscv/net/bpf_jit_core.c
409 ++++ b/arch/riscv/net/bpf_jit_core.c
410 +@@ -125,7 +125,8 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
411 +
412 + if (i == NR_JIT_ITERATIONS) {
413 + pr_err("bpf-jit: image did not converge in <%d passes!\n", i);
414 +- bpf_jit_binary_free(jit_data->header);
415 ++ if (jit_data->header)
416 ++ bpf_jit_binary_free(jit_data->header);
417 + prog = orig_prog;
418 + goto out_offset;
419 + }
420 +diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
421 +index 2bb9996ff09b4..e6c4f29fc6956 100644
422 +--- a/arch/s390/kvm/interrupt.c
423 ++++ b/arch/s390/kvm/interrupt.c
424 +@@ -3053,13 +3053,14 @@ static void __airqs_kick_single_vcpu(struct kvm *kvm, u8 deliverable_mask)
425 + int vcpu_idx, online_vcpus = atomic_read(&kvm->online_vcpus);
426 + struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int;
427 + struct kvm_vcpu *vcpu;
428 ++ u8 vcpu_isc_mask;
429 +
430 + for_each_set_bit(vcpu_idx, kvm->arch.idle_mask, online_vcpus) {
431 + vcpu = kvm_get_vcpu(kvm, vcpu_idx);
432 + if (psw_ioint_disabled(vcpu))
433 + continue;
434 +- deliverable_mask &= (u8)(vcpu->arch.sie_block->gcr[6] >> 24);
435 +- if (deliverable_mask) {
436 ++ vcpu_isc_mask = (u8)(vcpu->arch.sie_block->gcr[6] >> 24);
437 ++ if (deliverable_mask & vcpu_isc_mask) {
438 + /* lately kicked but not yet running */
439 + if (test_and_set_bit(vcpu_idx, gi->kicked_mask))
440 + return;
441 +diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
442 +index 7f719b468b440..00f03f363c9b0 100644
443 +--- a/arch/s390/kvm/kvm-s390.c
444 ++++ b/arch/s390/kvm/kvm-s390.c
445 +@@ -3312,6 +3312,7 @@ out_free_sie_block:
446 +
447 + int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
448 + {
449 ++ clear_bit(vcpu->vcpu_idx, vcpu->kvm->arch.gisa_int.kicked_mask);
450 + return kvm_s390_vcpu_has_irq(vcpu, 0);
451 + }
452 +
453 +diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
454 +index b62446ea5f408..11be88f70690e 100644
455 +--- a/drivers/ata/sata_mv.c
456 ++++ b/drivers/ata/sata_mv.c
457 +@@ -3892,8 +3892,8 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx)
458 + break;
459 +
460 + default:
461 +- dev_err(host->dev, "BUG: invalid board index %u\n", board_idx);
462 +- return 1;
463 ++ dev_alert(host->dev, "BUG: invalid board index %u\n", board_idx);
464 ++ return -EINVAL;
465 + }
466 +
467 + hpriv->hp_flags = hp_flags;
468 +diff --git a/drivers/base/regmap/regcache-rbtree.c b/drivers/base/regmap/regcache-rbtree.c
469 +index cfa29dc89bbff..fabf87058d80b 100644
470 +--- a/drivers/base/regmap/regcache-rbtree.c
471 ++++ b/drivers/base/regmap/regcache-rbtree.c
472 +@@ -281,14 +281,14 @@ static int regcache_rbtree_insert_to_block(struct regmap *map,
473 + if (!blk)
474 + return -ENOMEM;
475 +
476 ++ rbnode->block = blk;
477 ++
478 + if (BITS_TO_LONGS(blklen) > BITS_TO_LONGS(rbnode->blklen)) {
479 + present = krealloc(rbnode->cache_present,
480 + BITS_TO_LONGS(blklen) * sizeof(*present),
481 + GFP_KERNEL);
482 +- if (!present) {
483 +- kfree(blk);
484 ++ if (!present)
485 + return -ENOMEM;
486 +- }
487 +
488 + memset(present + BITS_TO_LONGS(rbnode->blklen), 0,
489 + (BITS_TO_LONGS(blklen) - BITS_TO_LONGS(rbnode->blklen))
490 +@@ -305,7 +305,6 @@ static int regcache_rbtree_insert_to_block(struct regmap *map,
491 + }
492 +
493 + /* update the rbnode block, its size and the base register */
494 +- rbnode->block = blk;
495 + rbnode->blklen = blklen;
496 + rbnode->base_reg = base_reg;
497 + rbnode->cache_present = present;
498 +diff --git a/drivers/gpio/gpio-xgs-iproc.c b/drivers/gpio/gpio-xgs-iproc.c
499 +index ad5489a65d542..dd40277b9d06d 100644
500 +--- a/drivers/gpio/gpio-xgs-iproc.c
501 ++++ b/drivers/gpio/gpio-xgs-iproc.c
502 +@@ -224,7 +224,7 @@ static int iproc_gpio_probe(struct platform_device *pdev)
503 + }
504 +
505 + chip->gc.label = dev_name(dev);
506 +- if (of_property_read_u32(dn, "ngpios", &num_gpios))
507 ++ if (!of_property_read_u32(dn, "ngpios", &num_gpios))
508 + chip->gc.ngpio = num_gpios;
509 +
510 + irq = platform_get_irq(pdev, 0);
511 +diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
512 +index fbb65c95464b3..e43f82bcb231a 100644
513 +--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
514 ++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
515 +@@ -264,7 +264,7 @@ static ssize_t dp_link_settings_write(struct file *f, const char __user *buf,
516 + if (!wr_buf)
517 + return -ENOSPC;
518 +
519 +- if (parse_write_buffer_into_params(wr_buf, size,
520 ++ if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
521 + (long *)param, buf,
522 + max_param_num,
523 + &param_nums)) {
524 +diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
525 +index fb2a25f8408fc..8fba425a76268 100644
526 +--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
527 ++++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
528 +@@ -322,6 +322,7 @@ static void ttm_transfered_destroy(struct ttm_buffer_object *bo)
529 + struct ttm_transfer_obj *fbo;
530 +
531 + fbo = container_of(bo, struct ttm_transfer_obj, base);
532 ++ dma_resv_fini(&fbo->base.base._resv);
533 + ttm_bo_put(fbo->bo);
534 + kfree(fbo);
535 + }
536 +diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
537 +index 8c930bf1df894..de88f472eaad2 100644
538 +--- a/drivers/infiniband/core/sa_query.c
539 ++++ b/drivers/infiniband/core/sa_query.c
540 +@@ -760,8 +760,9 @@ static void ib_nl_set_path_rec_attrs(struct sk_buff *skb,
541 +
542 + /* Construct the family header first */
543 + header = skb_put(skb, NLMSG_ALIGN(sizeof(*header)));
544 +- memcpy(header->device_name, dev_name(&query->port->agent->device->dev),
545 +- LS_DEVICE_NAME_MAX);
546 ++ strscpy_pad(header->device_name,
547 ++ dev_name(&query->port->agent->device->dev),
548 ++ LS_DEVICE_NAME_MAX);
549 + header->port_num = query->port->port_num;
550 +
551 + if ((comp_mask & IB_SA_PATH_REC_REVERSIBLE) &&
552 +diff --git a/drivers/infiniband/hw/hfi1/pio.c b/drivers/infiniband/hw/hfi1/pio.c
553 +index ff864f6f02667..1cd8f80f097a7 100644
554 +--- a/drivers/infiniband/hw/hfi1/pio.c
555 ++++ b/drivers/infiniband/hw/hfi1/pio.c
556 +@@ -920,6 +920,7 @@ void sc_disable(struct send_context *sc)
557 + {
558 + u64 reg;
559 + struct pio_buf *pbuf;
560 ++ LIST_HEAD(wake_list);
561 +
562 + if (!sc)
563 + return;
564 +@@ -954,19 +955,21 @@ void sc_disable(struct send_context *sc)
565 + spin_unlock(&sc->release_lock);
566 +
567 + write_seqlock(&sc->waitlock);
568 +- while (!list_empty(&sc->piowait)) {
569 ++ if (!list_empty(&sc->piowait))
570 ++ list_move(&sc->piowait, &wake_list);
571 ++ write_sequnlock(&sc->waitlock);
572 ++ while (!list_empty(&wake_list)) {
573 + struct iowait *wait;
574 + struct rvt_qp *qp;
575 + struct hfi1_qp_priv *priv;
576 +
577 +- wait = list_first_entry(&sc->piowait, struct iowait, list);
578 ++ wait = list_first_entry(&wake_list, struct iowait, list);
579 + qp = iowait_to_qp(wait);
580 + priv = qp->priv;
581 + list_del_init(&priv->s_iowait.list);
582 + priv->s_iowait.lock = NULL;
583 + hfi1_qp_wakeup(qp, RVT_S_WAIT_PIO | HFI1_S_WAIT_PIO_DRAIN);
584 + }
585 +- write_sequnlock(&sc->waitlock);
586 +
587 + spin_unlock_irq(&sc->alloc_lock);
588 + }
589 +diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
590 +index 011477356a1de..7a2bec0ac0055 100644
591 +--- a/drivers/infiniband/hw/mlx5/qp.c
592 ++++ b/drivers/infiniband/hw/mlx5/qp.c
593 +@@ -4216,6 +4216,8 @@ static int mlx5_ib_modify_dct(struct ib_qp *ibqp, struct ib_qp_attr *attr,
594 + MLX5_SET(dctc, dctc, mtu, attr->path_mtu);
595 + MLX5_SET(dctc, dctc, my_addr_index, attr->ah_attr.grh.sgid_index);
596 + MLX5_SET(dctc, dctc, hop_limit, attr->ah_attr.grh.hop_limit);
597 ++ if (attr->ah_attr.type == RDMA_AH_ATTR_TYPE_ROCE)
598 ++ MLX5_SET(dctc, dctc, eth_prio, attr->ah_attr.sl & 0x7);
599 +
600 + err = mlx5_core_create_dct(dev, &qp->dct.mdct, qp->dct.in,
601 + MLX5_ST_SZ_BYTES(create_dct_in), out,
602 +diff --git a/drivers/infiniband/hw/qib/qib_user_sdma.c b/drivers/infiniband/hw/qib/qib_user_sdma.c
603 +index a67599b5a550a..ac11943a5ddb0 100644
604 +--- a/drivers/infiniband/hw/qib/qib_user_sdma.c
605 ++++ b/drivers/infiniband/hw/qib/qib_user_sdma.c
606 +@@ -602,7 +602,7 @@ done:
607 + /*
608 + * How many pages in this iovec element?
609 + */
610 +-static int qib_user_sdma_num_pages(const struct iovec *iov)
611 ++static size_t qib_user_sdma_num_pages(const struct iovec *iov)
612 + {
613 + const unsigned long addr = (unsigned long) iov->iov_base;
614 + const unsigned long len = iov->iov_len;
615 +@@ -658,7 +658,7 @@ static void qib_user_sdma_free_pkt_frag(struct device *dev,
616 + static int qib_user_sdma_pin_pages(const struct qib_devdata *dd,
617 + struct qib_user_sdma_queue *pq,
618 + struct qib_user_sdma_pkt *pkt,
619 +- unsigned long addr, int tlen, int npages)
620 ++ unsigned long addr, int tlen, size_t npages)
621 + {
622 + struct page *pages[8];
623 + int i, j;
624 +@@ -722,7 +722,7 @@ static int qib_user_sdma_pin_pkt(const struct qib_devdata *dd,
625 + unsigned long idx;
626 +
627 + for (idx = 0; idx < niov; idx++) {
628 +- const int npages = qib_user_sdma_num_pages(iov + idx);
629 ++ const size_t npages = qib_user_sdma_num_pages(iov + idx);
630 + const unsigned long addr = (unsigned long) iov[idx].iov_base;
631 +
632 + ret = qib_user_sdma_pin_pages(dd, pq, pkt, addr,
633 +@@ -824,8 +824,8 @@ static int qib_user_sdma_queue_pkts(const struct qib_devdata *dd,
634 + unsigned pktnw;
635 + unsigned pktnwc;
636 + int nfrags = 0;
637 +- int npages = 0;
638 +- int bytes_togo = 0;
639 ++ size_t npages = 0;
640 ++ size_t bytes_togo = 0;
641 + int tiddma = 0;
642 + int cfur;
643 +
644 +@@ -885,7 +885,11 @@ static int qib_user_sdma_queue_pkts(const struct qib_devdata *dd,
645 +
646 + npages += qib_user_sdma_num_pages(&iov[idx]);
647 +
648 +- bytes_togo += slen;
649 ++ if (check_add_overflow(bytes_togo, slen, &bytes_togo) ||
650 ++ bytes_togo > type_max(typeof(pkt->bytes_togo))) {
651 ++ ret = -EINVAL;
652 ++ goto free_pbc;
653 ++ }
654 + pktnwc += slen >> 2;
655 + idx++;
656 + nfrags++;
657 +@@ -904,8 +908,7 @@ static int qib_user_sdma_queue_pkts(const struct qib_devdata *dd,
658 + }
659 +
660 + if (frag_size) {
661 +- int tidsmsize, n;
662 +- size_t pktsize;
663 ++ size_t tidsmsize, n, pktsize, sz, addrlimit;
664 +
665 + n = npages*((2*PAGE_SIZE/frag_size)+1);
666 + pktsize = struct_size(pkt, addr, n);
667 +@@ -923,14 +926,24 @@ static int qib_user_sdma_queue_pkts(const struct qib_devdata *dd,
668 + else
669 + tidsmsize = 0;
670 +
671 +- pkt = kmalloc(pktsize+tidsmsize, GFP_KERNEL);
672 ++ if (check_add_overflow(pktsize, tidsmsize, &sz)) {
673 ++ ret = -EINVAL;
674 ++ goto free_pbc;
675 ++ }
676 ++ pkt = kmalloc(sz, GFP_KERNEL);
677 + if (!pkt) {
678 + ret = -ENOMEM;
679 + goto free_pbc;
680 + }
681 + pkt->largepkt = 1;
682 + pkt->frag_size = frag_size;
683 +- pkt->addrlimit = n + ARRAY_SIZE(pkt->addr);
684 ++ if (check_add_overflow(n, ARRAY_SIZE(pkt->addr),
685 ++ &addrlimit) ||
686 ++ addrlimit > type_max(typeof(pkt->addrlimit))) {
687 ++ ret = -EINVAL;
688 ++ goto free_pbc;
689 ++ }
690 ++ pkt->addrlimit = addrlimit;
691 +
692 + if (tiddma) {
693 + char *tidsm = (char *)pkt + pktsize;
694 +diff --git a/drivers/mmc/host/cqhci.c b/drivers/mmc/host/cqhci.c
695 +index 697fe40756bf2..7ba4f714106f9 100644
696 +--- a/drivers/mmc/host/cqhci.c
697 ++++ b/drivers/mmc/host/cqhci.c
698 +@@ -273,6 +273,9 @@ static void __cqhci_enable(struct cqhci_host *cq_host)
699 +
700 + cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
701 +
702 ++ if (cqhci_readl(cq_host, CQHCI_CTL) & CQHCI_HALT)
703 ++ cqhci_writel(cq_host, 0, CQHCI_CTL);
704 ++
705 + mmc->cqe_on = true;
706 +
707 + if (cq_host->ops->enable)
708 +diff --git a/drivers/mmc/host/dw_mmc-exynos.c b/drivers/mmc/host/dw_mmc-exynos.c
709 +index 0c75810812a0a..1f8a3c0ddfe11 100644
710 +--- a/drivers/mmc/host/dw_mmc-exynos.c
711 ++++ b/drivers/mmc/host/dw_mmc-exynos.c
712 +@@ -464,6 +464,18 @@ static s8 dw_mci_exynos_get_best_clksmpl(u8 candiates)
713 + }
714 + }
715 +
716 ++ /*
717 ++ * If there is no cadiates value, then it needs to return -EIO.
718 ++ * If there are candiates values and don't find bset clk sample value,
719 ++ * then use a first candiates clock sample value.
720 ++ */
721 ++ for (i = 0; i < iter; i++) {
722 ++ __c = ror8(candiates, i);
723 ++ if ((__c & 0x1) == 0x1) {
724 ++ loc = i;
725 ++ goto out;
726 ++ }
727 ++ }
728 + out:
729 + return loc;
730 + }
731 +@@ -494,6 +506,8 @@ static int dw_mci_exynos_execute_tuning(struct dw_mci_slot *slot, u32 opcode)
732 + priv->tuned_sample = found;
733 + } else {
734 + ret = -EIO;
735 ++ dev_warn(&mmc->class_dev,
736 ++ "There is no candiates value about clksmpl!\n");
737 + }
738 +
739 + return ret;
740 +diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
741 +index dc84e2dff4085..fb8b9475b1d01 100644
742 +--- a/drivers/mmc/host/mtk-sd.c
743 ++++ b/drivers/mmc/host/mtk-sd.c
744 +@@ -2503,6 +2503,25 @@ static int msdc_drv_probe(struct platform_device *pdev)
745 + host->dma_mask = DMA_BIT_MASK(32);
746 + mmc_dev(mmc)->dma_mask = &host->dma_mask;
747 +
748 ++ host->timeout_clks = 3 * 1048576;
749 ++ host->dma.gpd = dma_alloc_coherent(&pdev->dev,
750 ++ 2 * sizeof(struct mt_gpdma_desc),
751 ++ &host->dma.gpd_addr, GFP_KERNEL);
752 ++ host->dma.bd = dma_alloc_coherent(&pdev->dev,
753 ++ MAX_BD_NUM * sizeof(struct mt_bdma_desc),
754 ++ &host->dma.bd_addr, GFP_KERNEL);
755 ++ if (!host->dma.gpd || !host->dma.bd) {
756 ++ ret = -ENOMEM;
757 ++ goto release_mem;
758 ++ }
759 ++ msdc_init_gpd_bd(host, &host->dma);
760 ++ INIT_DELAYED_WORK(&host->req_timeout, msdc_request_timeout);
761 ++ spin_lock_init(&host->lock);
762 ++
763 ++ platform_set_drvdata(pdev, mmc);
764 ++ msdc_ungate_clock(host);
765 ++ msdc_init_hw(host);
766 ++
767 + if (mmc->caps2 & MMC_CAP2_CQE) {
768 + host->cq_host = devm_kzalloc(mmc->parent,
769 + sizeof(*host->cq_host),
770 +@@ -2523,25 +2542,6 @@ static int msdc_drv_probe(struct platform_device *pdev)
771 + mmc->max_seg_size = 64 * 1024;
772 + }
773 +
774 +- host->timeout_clks = 3 * 1048576;
775 +- host->dma.gpd = dma_alloc_coherent(&pdev->dev,
776 +- 2 * sizeof(struct mt_gpdma_desc),
777 +- &host->dma.gpd_addr, GFP_KERNEL);
778 +- host->dma.bd = dma_alloc_coherent(&pdev->dev,
779 +- MAX_BD_NUM * sizeof(struct mt_bdma_desc),
780 +- &host->dma.bd_addr, GFP_KERNEL);
781 +- if (!host->dma.gpd || !host->dma.bd) {
782 +- ret = -ENOMEM;
783 +- goto release_mem;
784 +- }
785 +- msdc_init_gpd_bd(host, &host->dma);
786 +- INIT_DELAYED_WORK(&host->req_timeout, msdc_request_timeout);
787 +- spin_lock_init(&host->lock);
788 +-
789 +- platform_set_drvdata(pdev, mmc);
790 +- msdc_ungate_clock(host);
791 +- msdc_init_hw(host);
792 +-
793 + ret = devm_request_irq(&pdev->dev, host->irq, msdc_irq,
794 + IRQF_TRIGGER_NONE, pdev->name, host);
795 + if (ret)
796 +diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
797 +index d28809e479628..20cbd71cba9d9 100644
798 +--- a/drivers/mmc/host/sdhci-esdhc-imx.c
799 ++++ b/drivers/mmc/host/sdhci-esdhc-imx.c
800 +@@ -1157,6 +1157,7 @@ static void esdhc_reset_tuning(struct sdhci_host *host)
801 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
802 + struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
803 + u32 ctrl;
804 ++ int ret;
805 +
806 + /* Reset the tuning circuit */
807 + if (esdhc_is_usdhc(imx_data)) {
808 +@@ -1169,7 +1170,22 @@ static void esdhc_reset_tuning(struct sdhci_host *host)
809 + } else if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING) {
810 + ctrl = readl(host->ioaddr + SDHCI_AUTO_CMD_STATUS);
811 + ctrl &= ~ESDHC_MIX_CTRL_SMPCLK_SEL;
812 ++ ctrl &= ~ESDHC_MIX_CTRL_EXE_TUNE;
813 + writel(ctrl, host->ioaddr + SDHCI_AUTO_CMD_STATUS);
814 ++ /* Make sure ESDHC_MIX_CTRL_EXE_TUNE cleared */
815 ++ ret = readl_poll_timeout(host->ioaddr + SDHCI_AUTO_CMD_STATUS,
816 ++ ctrl, !(ctrl & ESDHC_MIX_CTRL_EXE_TUNE), 1, 50);
817 ++ if (ret == -ETIMEDOUT)
818 ++ dev_warn(mmc_dev(host->mmc),
819 ++ "Warning! clear execute tuning bit failed\n");
820 ++ /*
821 ++ * SDHCI_INT_DATA_AVAIL is W1C bit, set this bit will clear the
822 ++ * usdhc IP internal logic flag execute_tuning_with_clr_buf, which
823 ++ * will finally make sure the normal data transfer logic correct.
824 ++ */
825 ++ ctrl = readl(host->ioaddr + SDHCI_INT_STATUS);
826 ++ ctrl |= SDHCI_INT_DATA_AVAIL;
827 ++ writel(ctrl, host->ioaddr + SDHCI_INT_STATUS);
828 + }
829 + }
830 + }
831 +diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
832 +index b1e1d327cb8eb..07d131fac7606 100644
833 +--- a/drivers/mmc/host/sdhci.c
834 ++++ b/drivers/mmc/host/sdhci.c
835 +@@ -2043,6 +2043,12 @@ void sdhci_set_power_noreg(struct sdhci_host *host, unsigned char mode,
836 + break;
837 + case MMC_VDD_32_33:
838 + case MMC_VDD_33_34:
839 ++ /*
840 ++ * 3.4 ~ 3.6V are valid only for those platforms where it's
841 ++ * known that the voltage range is supported by hardware.
842 ++ */
843 ++ case MMC_VDD_34_35:
844 ++ case MMC_VDD_35_36:
845 + pwr = SDHCI_POWER_330;
846 + break;
847 + default:
848 +diff --git a/drivers/mmc/host/vub300.c b/drivers/mmc/host/vub300.c
849 +index 4950d10d3a191..97beece62fec4 100644
850 +--- a/drivers/mmc/host/vub300.c
851 ++++ b/drivers/mmc/host/vub300.c
852 +@@ -576,7 +576,7 @@ static void check_vub300_port_status(struct vub300_mmc_host *vub300)
853 + GET_SYSTEM_PORT_STATUS,
854 + USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
855 + 0x0000, 0x0000, &vub300->system_port_status,
856 +- sizeof(vub300->system_port_status), HZ);
857 ++ sizeof(vub300->system_port_status), 1000);
858 + if (sizeof(vub300->system_port_status) == retval)
859 + new_system_port_status(vub300);
860 + }
861 +@@ -1241,7 +1241,7 @@ static void __download_offload_pseudocode(struct vub300_mmc_host *vub300,
862 + SET_INTERRUPT_PSEUDOCODE,
863 + USB_DIR_OUT | USB_TYPE_VENDOR |
864 + USB_RECIP_DEVICE, 0x0000, 0x0000,
865 +- xfer_buffer, xfer_length, HZ);
866 ++ xfer_buffer, xfer_length, 1000);
867 + kfree(xfer_buffer);
868 + if (retval < 0)
869 + goto copy_error_message;
870 +@@ -1284,7 +1284,7 @@ static void __download_offload_pseudocode(struct vub300_mmc_host *vub300,
871 + SET_TRANSFER_PSEUDOCODE,
872 + USB_DIR_OUT | USB_TYPE_VENDOR |
873 + USB_RECIP_DEVICE, 0x0000, 0x0000,
874 +- xfer_buffer, xfer_length, HZ);
875 ++ xfer_buffer, xfer_length, 1000);
876 + kfree(xfer_buffer);
877 + if (retval < 0)
878 + goto copy_error_message;
879 +@@ -1991,7 +1991,7 @@ static void __set_clock_speed(struct vub300_mmc_host *vub300, u8 buf[8],
880 + usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0),
881 + SET_CLOCK_SPEED,
882 + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
883 +- 0x00, 0x00, buf, buf_array_size, HZ);
884 ++ 0x00, 0x00, buf, buf_array_size, 1000);
885 + if (retval != 8) {
886 + dev_err(&vub300->udev->dev, "SET_CLOCK_SPEED"
887 + " %dkHz failed with retval=%d\n", kHzClock, retval);
888 +@@ -2013,14 +2013,14 @@ static void vub300_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
889 + usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0),
890 + SET_SD_POWER,
891 + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
892 +- 0x0000, 0x0000, NULL, 0, HZ);
893 ++ 0x0000, 0x0000, NULL, 0, 1000);
894 + /* must wait for the VUB300 u-proc to boot up */
895 + msleep(600);
896 + } else if ((ios->power_mode == MMC_POWER_UP) && !vub300->card_powered) {
897 + usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0),
898 + SET_SD_POWER,
899 + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
900 +- 0x0001, 0x0000, NULL, 0, HZ);
901 ++ 0x0001, 0x0000, NULL, 0, 1000);
902 + msleep(600);
903 + vub300->card_powered = 1;
904 + } else if (ios->power_mode == MMC_POWER_ON) {
905 +@@ -2275,14 +2275,14 @@ static int vub300_probe(struct usb_interface *interface,
906 + GET_HC_INF0,
907 + USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
908 + 0x0000, 0x0000, &vub300->hc_info,
909 +- sizeof(vub300->hc_info), HZ);
910 ++ sizeof(vub300->hc_info), 1000);
911 + if (retval < 0)
912 + goto error5;
913 + retval =
914 + usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0),
915 + SET_ROM_WAIT_STATES,
916 + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
917 +- firmware_rom_wait_states, 0x0000, NULL, 0, HZ);
918 ++ firmware_rom_wait_states, 0x0000, NULL, 0, 1000);
919 + if (retval < 0)
920 + goto error5;
921 + dev_info(&vub300->udev->dev,
922 +@@ -2297,7 +2297,7 @@ static int vub300_probe(struct usb_interface *interface,
923 + GET_SYSTEM_PORT_STATUS,
924 + USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
925 + 0x0000, 0x0000, &vub300->system_port_status,
926 +- sizeof(vub300->system_port_status), HZ);
927 ++ sizeof(vub300->system_port_status), 1000);
928 + if (retval < 0) {
929 + goto error4;
930 + } else if (sizeof(vub300->system_port_status) == retval) {
931 +diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
932 +index bc870bff14df7..5205796859f6c 100644
933 +--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
934 ++++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
935 +@@ -139,18 +139,85 @@ static const struct file_operations rvu_dbg_##name##_fops = { \
936 +
937 + static void print_nix_qsize(struct seq_file *filp, struct rvu_pfvf *pfvf);
938 +
939 ++static void get_lf_str_list(struct rvu_block block, int pcifunc,
940 ++ char *lfs)
941 ++{
942 ++ int lf = 0, seq = 0, len = 0, prev_lf = block.lf.max;
943 ++
944 ++ for_each_set_bit(lf, block.lf.bmap, block.lf.max) {
945 ++ if (lf >= block.lf.max)
946 ++ break;
947 ++
948 ++ if (block.fn_map[lf] != pcifunc)
949 ++ continue;
950 ++
951 ++ if (lf == prev_lf + 1) {
952 ++ prev_lf = lf;
953 ++ seq = 1;
954 ++ continue;
955 ++ }
956 ++
957 ++ if (seq)
958 ++ len += sprintf(lfs + len, "-%d,%d", prev_lf, lf);
959 ++ else
960 ++ len += (len ? sprintf(lfs + len, ",%d", lf) :
961 ++ sprintf(lfs + len, "%d", lf));
962 ++
963 ++ prev_lf = lf;
964 ++ seq = 0;
965 ++ }
966 ++
967 ++ if (seq)
968 ++ len += sprintf(lfs + len, "-%d", prev_lf);
969 ++
970 ++ lfs[len] = '\0';
971 ++}
972 ++
973 ++static int get_max_column_width(struct rvu *rvu)
974 ++{
975 ++ int index, pf, vf, lf_str_size = 12, buf_size = 256;
976 ++ struct rvu_block block;
977 ++ u16 pcifunc;
978 ++ char *buf;
979 ++
980 ++ buf = kzalloc(buf_size, GFP_KERNEL);
981 ++ if (!buf)
982 ++ return -ENOMEM;
983 ++
984 ++ for (pf = 0; pf < rvu->hw->total_pfs; pf++) {
985 ++ for (vf = 0; vf <= rvu->hw->total_vfs; vf++) {
986 ++ pcifunc = pf << 10 | vf;
987 ++ if (!pcifunc)
988 ++ continue;
989 ++
990 ++ for (index = 0; index < BLK_COUNT; index++) {
991 ++ block = rvu->hw->block[index];
992 ++ if (!strlen(block.name))
993 ++ continue;
994 ++
995 ++ get_lf_str_list(block, pcifunc, buf);
996 ++ if (lf_str_size <= strlen(buf))
997 ++ lf_str_size = strlen(buf) + 1;
998 ++ }
999 ++ }
1000 ++ }
1001 ++
1002 ++ kfree(buf);
1003 ++ return lf_str_size;
1004 ++}
1005 ++
1006 + /* Dumps current provisioning status of all RVU block LFs */
1007 + static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
1008 + char __user *buffer,
1009 + size_t count, loff_t *ppos)
1010 + {
1011 +- int index, off = 0, flag = 0, go_back = 0, len = 0;
1012 ++ int index, off = 0, flag = 0, len = 0, i = 0;
1013 + struct rvu *rvu = filp->private_data;
1014 +- int lf, pf, vf, pcifunc;
1015 ++ int bytes_not_copied = 0;
1016 + struct rvu_block block;
1017 +- int bytes_not_copied;
1018 +- int lf_str_size = 12;
1019 ++ int pf, vf, pcifunc;
1020 + int buf_size = 2048;
1021 ++ int lf_str_size;
1022 + char *lfs;
1023 + char *buf;
1024 +
1025 +@@ -162,6 +229,9 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
1026 + if (!buf)
1027 + return -ENOSPC;
1028 +
1029 ++ /* Get the maximum width of a column */
1030 ++ lf_str_size = get_max_column_width(rvu);
1031 ++
1032 + lfs = kzalloc(lf_str_size, GFP_KERNEL);
1033 + if (!lfs) {
1034 + kfree(buf);
1035 +@@ -175,65 +245,69 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
1036 + "%-*s", lf_str_size,
1037 + rvu->hw->block[index].name);
1038 + }
1039 ++
1040 + off += scnprintf(&buf[off], buf_size - 1 - off, "\n");
1041 ++ bytes_not_copied = copy_to_user(buffer + (i * off), buf, off);
1042 ++ if (bytes_not_copied)
1043 ++ goto out;
1044 ++
1045 ++ i++;
1046 ++ *ppos += off;
1047 + for (pf = 0; pf < rvu->hw->total_pfs; pf++) {
1048 + for (vf = 0; vf <= rvu->hw->total_vfs; vf++) {
1049 ++ off = 0;
1050 ++ flag = 0;
1051 + pcifunc = pf << 10 | vf;
1052 + if (!pcifunc)
1053 + continue;
1054 +
1055 + if (vf) {
1056 + sprintf(lfs, "PF%d:VF%d", pf, vf - 1);
1057 +- go_back = scnprintf(&buf[off],
1058 +- buf_size - 1 - off,
1059 +- "%-*s", lf_str_size, lfs);
1060 ++ off = scnprintf(&buf[off],
1061 ++ buf_size - 1 - off,
1062 ++ "%-*s", lf_str_size, lfs);
1063 + } else {
1064 + sprintf(lfs, "PF%d", pf);
1065 +- go_back = scnprintf(&buf[off],
1066 +- buf_size - 1 - off,
1067 +- "%-*s", lf_str_size, lfs);
1068 ++ off = scnprintf(&buf[off],
1069 ++ buf_size - 1 - off,
1070 ++ "%-*s", lf_str_size, lfs);
1071 + }
1072 +
1073 +- off += go_back;
1074 +- for (index = 0; index < BLKTYPE_MAX; index++) {
1075 ++ for (index = 0; index < BLK_COUNT; index++) {
1076 + block = rvu->hw->block[index];
1077 + if (!strlen(block.name))
1078 + continue;
1079 + len = 0;
1080 + lfs[len] = '\0';
1081 +- for (lf = 0; lf < block.lf.max; lf++) {
1082 +- if (block.fn_map[lf] != pcifunc)
1083 +- continue;
1084 ++ get_lf_str_list(block, pcifunc, lfs);
1085 ++ if (strlen(lfs))
1086 + flag = 1;
1087 +- len += sprintf(&lfs[len], "%d,", lf);
1088 +- }
1089 +
1090 +- if (flag)
1091 +- len--;
1092 +- lfs[len] = '\0';
1093 + off += scnprintf(&buf[off], buf_size - 1 - off,
1094 + "%-*s", lf_str_size, lfs);
1095 +- if (!strlen(lfs))
1096 +- go_back += lf_str_size;
1097 + }
1098 +- if (!flag)
1099 +- off -= go_back;
1100 +- else
1101 +- flag = 0;
1102 +- off--;
1103 +- off += scnprintf(&buf[off], buf_size - 1 - off, "\n");
1104 ++ if (flag) {
1105 ++ off += scnprintf(&buf[off],
1106 ++ buf_size - 1 - off, "\n");
1107 ++ bytes_not_copied = copy_to_user(buffer +
1108 ++ (i * off),
1109 ++ buf, off);
1110 ++ if (bytes_not_copied)
1111 ++ goto out;
1112 ++
1113 ++ i++;
1114 ++ *ppos += off;
1115 ++ }
1116 + }
1117 + }
1118 +
1119 +- bytes_not_copied = copy_to_user(buffer, buf, off);
1120 ++out:
1121 + kfree(lfs);
1122 + kfree(buf);
1123 +-
1124 + if (bytes_not_copied)
1125 + return -EFAULT;
1126 +
1127 +- *ppos = off;
1128 +- return off;
1129 ++ return *ppos;
1130 + }
1131 +
1132 + RVU_DEBUG_FOPS(rsrc_status, rsrc_attach_status, NULL);
1133 +diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c
1134 +index 641cdd81882b8..ffaeda75eec42 100644
1135 +--- a/drivers/net/ethernet/mellanox/mlxsw/pci.c
1136 ++++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c
1137 +@@ -353,13 +353,10 @@ static int mlxsw_pci_rdq_skb_alloc(struct mlxsw_pci *mlxsw_pci,
1138 + struct sk_buff *skb;
1139 + int err;
1140 +
1141 +- elem_info->u.rdq.skb = NULL;
1142 + skb = netdev_alloc_skb_ip_align(NULL, buf_len);
1143 + if (!skb)
1144 + return -ENOMEM;
1145 +
1146 +- /* Assume that wqe was previously zeroed. */
1147 +-
1148 + err = mlxsw_pci_wqe_frag_map(mlxsw_pci, wqe, 0, skb->data,
1149 + buf_len, DMA_FROM_DEVICE);
1150 + if (err)
1151 +@@ -548,21 +545,26 @@ static void mlxsw_pci_cqe_rdq_handle(struct mlxsw_pci *mlxsw_pci,
1152 + struct pci_dev *pdev = mlxsw_pci->pdev;
1153 + struct mlxsw_pci_queue_elem_info *elem_info;
1154 + struct mlxsw_rx_info rx_info = {};
1155 +- char *wqe;
1156 ++ char wqe[MLXSW_PCI_WQE_SIZE];
1157 + struct sk_buff *skb;
1158 + u16 byte_count;
1159 + int err;
1160 +
1161 + elem_info = mlxsw_pci_queue_elem_info_consumer_get(q);
1162 +- skb = elem_info->u.sdq.skb;
1163 +- if (!skb)
1164 +- return;
1165 +- wqe = elem_info->elem;
1166 +- mlxsw_pci_wqe_frag_unmap(mlxsw_pci, wqe, 0, DMA_FROM_DEVICE);
1167 ++ skb = elem_info->u.rdq.skb;
1168 ++ memcpy(wqe, elem_info->elem, MLXSW_PCI_WQE_SIZE);
1169 +
1170 + if (q->consumer_counter++ != consumer_counter_limit)
1171 + dev_dbg_ratelimited(&pdev->dev, "Consumer counter does not match limit in RDQ\n");
1172 +
1173 ++ err = mlxsw_pci_rdq_skb_alloc(mlxsw_pci, elem_info);
1174 ++ if (err) {
1175 ++ dev_err_ratelimited(&pdev->dev, "Failed to alloc skb for RDQ\n");
1176 ++ goto out;
1177 ++ }
1178 ++
1179 ++ mlxsw_pci_wqe_frag_unmap(mlxsw_pci, wqe, 0, DMA_FROM_DEVICE);
1180 ++
1181 + if (mlxsw_pci_cqe_lag_get(cqe_v, cqe)) {
1182 + rx_info.is_lag = true;
1183 + rx_info.u.lag_id = mlxsw_pci_cqe_lag_id_get(cqe_v, cqe);
1184 +@@ -594,10 +596,7 @@ static void mlxsw_pci_cqe_rdq_handle(struct mlxsw_pci *mlxsw_pci,
1185 + skb_put(skb, byte_count);
1186 + mlxsw_core_skb_receive(mlxsw_pci->core, skb, &rx_info);
1187 +
1188 +- memset(wqe, 0, q->elem_size);
1189 +- err = mlxsw_pci_rdq_skb_alloc(mlxsw_pci, elem_info);
1190 +- if (err)
1191 +- dev_dbg_ratelimited(&pdev->dev, "Failed to alloc skb for RDQ\n");
1192 ++out:
1193 + /* Everything is set up, ring doorbell to pass elem to HW */
1194 + q->producer_counter++;
1195 + mlxsw_pci_queue_doorbell_producer_ring(mlxsw_pci, q);
1196 +diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
1197 +index 8947c3a628109..e14dfaafe4391 100644
1198 +--- a/drivers/net/ethernet/microchip/lan743x_main.c
1199 ++++ b/drivers/net/ethernet/microchip/lan743x_main.c
1200 +@@ -1280,7 +1280,7 @@ static void lan743x_tx_release_desc(struct lan743x_tx *tx,
1201 + if (!(buffer_info->flags & TX_BUFFER_INFO_FLAG_ACTIVE))
1202 + goto done;
1203 +
1204 +- descriptor_type = (descriptor->data0) &
1205 ++ descriptor_type = le32_to_cpu(descriptor->data0) &
1206 + TX_DESC_DATA0_DTYPE_MASK_;
1207 + if (descriptor_type == TX_DESC_DATA0_DTYPE_DATA_)
1208 + goto clean_up_data_descriptor;
1209 +@@ -1340,7 +1340,7 @@ static int lan743x_tx_next_index(struct lan743x_tx *tx, int index)
1210 +
1211 + static void lan743x_tx_release_completed_descriptors(struct lan743x_tx *tx)
1212 + {
1213 +- while ((*tx->head_cpu_ptr) != (tx->last_head)) {
1214 ++ while (le32_to_cpu(*tx->head_cpu_ptr) != (tx->last_head)) {
1215 + lan743x_tx_release_desc(tx, tx->last_head, false);
1216 + tx->last_head = lan743x_tx_next_index(tx, tx->last_head);
1217 + }
1218 +@@ -1426,10 +1426,10 @@ static int lan743x_tx_frame_start(struct lan743x_tx *tx,
1219 + if (dma_mapping_error(dev, dma_ptr))
1220 + return -ENOMEM;
1221 +
1222 +- tx_descriptor->data1 = DMA_ADDR_LOW32(dma_ptr);
1223 +- tx_descriptor->data2 = DMA_ADDR_HIGH32(dma_ptr);
1224 +- tx_descriptor->data3 = (frame_length << 16) &
1225 +- TX_DESC_DATA3_FRAME_LENGTH_MSS_MASK_;
1226 ++ tx_descriptor->data1 = cpu_to_le32(DMA_ADDR_LOW32(dma_ptr));
1227 ++ tx_descriptor->data2 = cpu_to_le32(DMA_ADDR_HIGH32(dma_ptr));
1228 ++ tx_descriptor->data3 = cpu_to_le32((frame_length << 16) &
1229 ++ TX_DESC_DATA3_FRAME_LENGTH_MSS_MASK_);
1230 +
1231 + buffer_info->skb = NULL;
1232 + buffer_info->dma_ptr = dma_ptr;
1233 +@@ -1470,7 +1470,7 @@ static void lan743x_tx_frame_add_lso(struct lan743x_tx *tx,
1234 + tx->frame_data0 |= TX_DESC_DATA0_IOC_;
1235 + }
1236 + tx_descriptor = &tx->ring_cpu_ptr[tx->frame_tail];
1237 +- tx_descriptor->data0 = tx->frame_data0;
1238 ++ tx_descriptor->data0 = cpu_to_le32(tx->frame_data0);
1239 +
1240 + /* move to next descriptor */
1241 + tx->frame_tail = lan743x_tx_next_index(tx, tx->frame_tail);
1242 +@@ -1514,7 +1514,7 @@ static int lan743x_tx_frame_add_fragment(struct lan743x_tx *tx,
1243 +
1244 + /* wrap up previous descriptor */
1245 + tx_descriptor = &tx->ring_cpu_ptr[tx->frame_tail];
1246 +- tx_descriptor->data0 = tx->frame_data0;
1247 ++ tx_descriptor->data0 = cpu_to_le32(tx->frame_data0);
1248 +
1249 + /* move to next descriptor */
1250 + tx->frame_tail = lan743x_tx_next_index(tx, tx->frame_tail);
1251 +@@ -1540,10 +1540,10 @@ static int lan743x_tx_frame_add_fragment(struct lan743x_tx *tx,
1252 + return -ENOMEM;
1253 + }
1254 +
1255 +- tx_descriptor->data1 = DMA_ADDR_LOW32(dma_ptr);
1256 +- tx_descriptor->data2 = DMA_ADDR_HIGH32(dma_ptr);
1257 +- tx_descriptor->data3 = (frame_length << 16) &
1258 +- TX_DESC_DATA3_FRAME_LENGTH_MSS_MASK_;
1259 ++ tx_descriptor->data1 = cpu_to_le32(DMA_ADDR_LOW32(dma_ptr));
1260 ++ tx_descriptor->data2 = cpu_to_le32(DMA_ADDR_HIGH32(dma_ptr));
1261 ++ tx_descriptor->data3 = cpu_to_le32((frame_length << 16) &
1262 ++ TX_DESC_DATA3_FRAME_LENGTH_MSS_MASK_);
1263 +
1264 + buffer_info->skb = NULL;
1265 + buffer_info->dma_ptr = dma_ptr;
1266 +@@ -1587,7 +1587,7 @@ static void lan743x_tx_frame_end(struct lan743x_tx *tx,
1267 + if (ignore_sync)
1268 + buffer_info->flags |= TX_BUFFER_INFO_FLAG_IGNORE_SYNC;
1269 +
1270 +- tx_descriptor->data0 = tx->frame_data0;
1271 ++ tx_descriptor->data0 = cpu_to_le32(tx->frame_data0);
1272 + tx->frame_tail = lan743x_tx_next_index(tx, tx->frame_tail);
1273 + tx->last_tail = tx->frame_tail;
1274 +
1275 +@@ -1770,6 +1770,16 @@ static int lan743x_tx_ring_init(struct lan743x_tx *tx)
1276 + ret = -EINVAL;
1277 + goto cleanup;
1278 + }
1279 ++ if (dma_set_mask_and_coherent(&tx->adapter->pdev->dev,
1280 ++ DMA_BIT_MASK(64))) {
1281 ++ if (dma_set_mask_and_coherent(&tx->adapter->pdev->dev,
1282 ++ DMA_BIT_MASK(32))) {
1283 ++ dev_warn(&tx->adapter->pdev->dev,
1284 ++ "lan743x_: No suitable DMA available\n");
1285 ++ ret = -ENOMEM;
1286 ++ goto cleanup;
1287 ++ }
1288 ++ }
1289 + ring_allocation_size = ALIGN(tx->ring_size *
1290 + sizeof(struct lan743x_tx_descriptor),
1291 + PAGE_SIZE);
1292 +@@ -1994,11 +2004,11 @@ static int lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index,
1293 + }
1294 +
1295 + buffer_info->buffer_length = length;
1296 +- descriptor->data1 = DMA_ADDR_LOW32(buffer_info->dma_ptr);
1297 +- descriptor->data2 = DMA_ADDR_HIGH32(buffer_info->dma_ptr);
1298 ++ descriptor->data1 = cpu_to_le32(DMA_ADDR_LOW32(buffer_info->dma_ptr));
1299 ++ descriptor->data2 = cpu_to_le32(DMA_ADDR_HIGH32(buffer_info->dma_ptr));
1300 + descriptor->data3 = 0;
1301 +- descriptor->data0 = (RX_DESC_DATA0_OWN_ |
1302 +- (length & RX_DESC_DATA0_BUF_LENGTH_MASK_));
1303 ++ descriptor->data0 = cpu_to_le32((RX_DESC_DATA0_OWN_ |
1304 ++ (length & RX_DESC_DATA0_BUF_LENGTH_MASK_)));
1305 + skb_reserve(buffer_info->skb, RX_HEAD_PADDING);
1306 + lan743x_rx_update_tail(rx, index);
1307 +
1308 +@@ -2013,12 +2023,12 @@ static void lan743x_rx_reuse_ring_element(struct lan743x_rx *rx, int index)
1309 + descriptor = &rx->ring_cpu_ptr[index];
1310 + buffer_info = &rx->buffer_info[index];
1311 +
1312 +- descriptor->data1 = DMA_ADDR_LOW32(buffer_info->dma_ptr);
1313 +- descriptor->data2 = DMA_ADDR_HIGH32(buffer_info->dma_ptr);
1314 ++ descriptor->data1 = cpu_to_le32(DMA_ADDR_LOW32(buffer_info->dma_ptr));
1315 ++ descriptor->data2 = cpu_to_le32(DMA_ADDR_HIGH32(buffer_info->dma_ptr));
1316 + descriptor->data3 = 0;
1317 +- descriptor->data0 = (RX_DESC_DATA0_OWN_ |
1318 ++ descriptor->data0 = cpu_to_le32((RX_DESC_DATA0_OWN_ |
1319 + ((buffer_info->buffer_length) &
1320 +- RX_DESC_DATA0_BUF_LENGTH_MASK_));
1321 ++ RX_DESC_DATA0_BUF_LENGTH_MASK_)));
1322 + lan743x_rx_update_tail(rx, index);
1323 + }
1324 +
1325 +@@ -2052,7 +2062,7 @@ static int lan743x_rx_process_packet(struct lan743x_rx *rx)
1326 + {
1327 + struct skb_shared_hwtstamps *hwtstamps = NULL;
1328 + int result = RX_PROCESS_RESULT_NOTHING_TO_DO;
1329 +- int current_head_index = *rx->head_cpu_ptr;
1330 ++ int current_head_index = le32_to_cpu(*rx->head_cpu_ptr);
1331 + struct lan743x_rx_buffer_info *buffer_info;
1332 + struct lan743x_rx_descriptor *descriptor;
1333 + int extension_index = -1;
1334 +@@ -2067,14 +2077,14 @@ static int lan743x_rx_process_packet(struct lan743x_rx *rx)
1335 +
1336 + if (rx->last_head != current_head_index) {
1337 + descriptor = &rx->ring_cpu_ptr[rx->last_head];
1338 +- if (descriptor->data0 & RX_DESC_DATA0_OWN_)
1339 ++ if (le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_OWN_)
1340 + goto done;
1341 +
1342 +- if (!(descriptor->data0 & RX_DESC_DATA0_FS_))
1343 ++ if (!(le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_FS_))
1344 + goto done;
1345 +
1346 + first_index = rx->last_head;
1347 +- if (descriptor->data0 & RX_DESC_DATA0_LS_) {
1348 ++ if (le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_LS_) {
1349 + last_index = rx->last_head;
1350 + } else {
1351 + int index;
1352 +@@ -2082,10 +2092,10 @@ static int lan743x_rx_process_packet(struct lan743x_rx *rx)
1353 + index = lan743x_rx_next_index(rx, first_index);
1354 + while (index != current_head_index) {
1355 + descriptor = &rx->ring_cpu_ptr[index];
1356 +- if (descriptor->data0 & RX_DESC_DATA0_OWN_)
1357 ++ if (le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_OWN_)
1358 + goto done;
1359 +
1360 +- if (descriptor->data0 & RX_DESC_DATA0_LS_) {
1361 ++ if (le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_LS_) {
1362 + last_index = index;
1363 + break;
1364 + }
1365 +@@ -2094,17 +2104,17 @@ static int lan743x_rx_process_packet(struct lan743x_rx *rx)
1366 + }
1367 + if (last_index >= 0) {
1368 + descriptor = &rx->ring_cpu_ptr[last_index];
1369 +- if (descriptor->data0 & RX_DESC_DATA0_EXT_) {
1370 ++ if (le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_EXT_) {
1371 + /* extension is expected to follow */
1372 + int index = lan743x_rx_next_index(rx,
1373 + last_index);
1374 + if (index != current_head_index) {
1375 + descriptor = &rx->ring_cpu_ptr[index];
1376 +- if (descriptor->data0 &
1377 ++ if (le32_to_cpu(descriptor->data0) &
1378 + RX_DESC_DATA0_OWN_) {
1379 + goto done;
1380 + }
1381 +- if (descriptor->data0 &
1382 ++ if (le32_to_cpu(descriptor->data0) &
1383 + RX_DESC_DATA0_EXT_) {
1384 + extension_index = index;
1385 + } else {
1386 +@@ -2156,7 +2166,7 @@ static int lan743x_rx_process_packet(struct lan743x_rx *rx)
1387 + }
1388 + buffer_info->skb = NULL;
1389 + packet_length = RX_DESC_DATA0_FRAME_LENGTH_GET_
1390 +- (descriptor->data0);
1391 ++ (le32_to_cpu(descriptor->data0));
1392 + skb_put(skb, packet_length - 4);
1393 + skb->protocol = eth_type_trans(skb,
1394 + rx->adapter->netdev);
1395 +@@ -2194,8 +2204,8 @@ process_extension:
1396 + descriptor = &rx->ring_cpu_ptr[extension_index];
1397 + buffer_info = &rx->buffer_info[extension_index];
1398 +
1399 +- ts_sec = descriptor->data1;
1400 +- ts_nsec = (descriptor->data2 &
1401 ++ ts_sec = le32_to_cpu(descriptor->data1);
1402 ++ ts_nsec = (le32_to_cpu(descriptor->data2) &
1403 + RX_DESC_DATA2_TS_NS_MASK_);
1404 + lan743x_rx_reuse_ring_element(rx, extension_index);
1405 + real_last_index = extension_index;
1406 +@@ -2318,6 +2328,16 @@ static int lan743x_rx_ring_init(struct lan743x_rx *rx)
1407 + ret = -EINVAL;
1408 + goto cleanup;
1409 + }
1410 ++ if (dma_set_mask_and_coherent(&rx->adapter->pdev->dev,
1411 ++ DMA_BIT_MASK(64))) {
1412 ++ if (dma_set_mask_and_coherent(&rx->adapter->pdev->dev,
1413 ++ DMA_BIT_MASK(32))) {
1414 ++ dev_warn(&rx->adapter->pdev->dev,
1415 ++ "lan743x_: No suitable DMA available\n");
1416 ++ ret = -ENOMEM;
1417 ++ goto cleanup;
1418 ++ }
1419 ++ }
1420 + ring_allocation_size = ALIGN(rx->ring_size *
1421 + sizeof(struct lan743x_rx_descriptor),
1422 + PAGE_SIZE);
1423 +@@ -3066,6 +3086,8 @@ static int lan743x_pm_resume(struct device *dev)
1424 + if (ret) {
1425 + netif_err(adapter, probe, adapter->netdev,
1426 + "lan743x_hardware_init returned %d\n", ret);
1427 ++ lan743x_pci_cleanup(adapter);
1428 ++ return ret;
1429 + }
1430 +
1431 + /* open netdev when netdev is at running state while resume.
1432 +diff --git a/drivers/net/ethernet/microchip/lan743x_main.h b/drivers/net/ethernet/microchip/lan743x_main.h
1433 +index a536f4a4994df..751f2bc9ce84e 100644
1434 +--- a/drivers/net/ethernet/microchip/lan743x_main.h
1435 ++++ b/drivers/net/ethernet/microchip/lan743x_main.h
1436 +@@ -660,7 +660,7 @@ struct lan743x_tx {
1437 +
1438 + struct lan743x_tx_buffer_info *buffer_info;
1439 +
1440 +- u32 *head_cpu_ptr;
1441 ++ __le32 *head_cpu_ptr;
1442 + dma_addr_t head_dma_ptr;
1443 + int last_head;
1444 + int last_tail;
1445 +@@ -690,7 +690,7 @@ struct lan743x_rx {
1446 +
1447 + struct lan743x_rx_buffer_info *buffer_info;
1448 +
1449 +- u32 *head_cpu_ptr;
1450 ++ __le32 *head_cpu_ptr;
1451 + dma_addr_t head_dma_ptr;
1452 + u32 last_head;
1453 + u32 last_tail;
1454 +@@ -775,10 +775,10 @@ struct lan743x_adapter {
1455 + #define TX_DESC_DATA3_FRAME_LENGTH_MSS_MASK_ (0x3FFF0000)
1456 +
1457 + struct lan743x_tx_descriptor {
1458 +- u32 data0;
1459 +- u32 data1;
1460 +- u32 data2;
1461 +- u32 data3;
1462 ++ __le32 data0;
1463 ++ __le32 data1;
1464 ++ __le32 data2;
1465 ++ __le32 data3;
1466 + } __aligned(DEFAULT_DMA_DESCRIPTOR_SPACING);
1467 +
1468 + #define TX_BUFFER_INFO_FLAG_ACTIVE BIT(0)
1469 +@@ -813,10 +813,10 @@ struct lan743x_tx_buffer_info {
1470 + #define RX_HEAD_PADDING NET_IP_ALIGN
1471 +
1472 + struct lan743x_rx_descriptor {
1473 +- u32 data0;
1474 +- u32 data1;
1475 +- u32 data2;
1476 +- u32 data3;
1477 ++ __le32 data0;
1478 ++ __le32 data1;
1479 ++ __le32 data2;
1480 ++ __le32 data3;
1481 + } __aligned(DEFAULT_DMA_DESCRIPTOR_SPACING);
1482 +
1483 + #define RX_BUFFER_INFO_FLAG_ACTIVE BIT(0)
1484 +diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
1485 +index d3cbb4215f5cf..9e098e40fb1c6 100644
1486 +--- a/drivers/net/ethernet/nxp/lpc_eth.c
1487 ++++ b/drivers/net/ethernet/nxp/lpc_eth.c
1488 +@@ -1015,9 +1015,6 @@ static int lpc_eth_close(struct net_device *ndev)
1489 + napi_disable(&pldat->napi);
1490 + netif_stop_queue(ndev);
1491 +
1492 +- if (ndev->phydev)
1493 +- phy_stop(ndev->phydev);
1494 +-
1495 + spin_lock_irqsave(&pldat->lock, flags);
1496 + __lpc_eth_reset(pldat);
1497 + netif_carrier_off(ndev);
1498 +@@ -1025,6 +1022,8 @@ static int lpc_eth_close(struct net_device *ndev)
1499 + writel(0, LPC_ENET_MAC2(pldat->net_base));
1500 + spin_unlock_irqrestore(&pldat->lock, flags);
1501 +
1502 ++ if (ndev->phydev)
1503 ++ phy_stop(ndev->phydev);
1504 + clk_disable_unprepare(pldat->clk);
1505 +
1506 + return 0;
1507 +diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
1508 +index 453490be7055a..2645ca35103c9 100644
1509 +--- a/drivers/net/phy/mdio_bus.c
1510 ++++ b/drivers/net/phy/mdio_bus.c
1511 +@@ -544,7 +544,6 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner)
1512 + err = device_register(&bus->dev);
1513 + if (err) {
1514 + pr_err("mii_bus %s failed to register\n", bus->id);
1515 +- put_device(&bus->dev);
1516 + return -EINVAL;
1517 + }
1518 +
1519 +diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
1520 +index 28ddaad721ed1..5ee7cde0c2e97 100644
1521 +--- a/drivers/net/phy/phy.c
1522 ++++ b/drivers/net/phy/phy.c
1523 +@@ -260,62 +260,10 @@ static void phy_sanitize_settings(struct phy_device *phydev)
1524 + }
1525 + }
1526 +
1527 +-int phy_ethtool_ksettings_set(struct phy_device *phydev,
1528 +- const struct ethtool_link_ksettings *cmd)
1529 +-{
1530 +- __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising);
1531 +- u8 autoneg = cmd->base.autoneg;
1532 +- u8 duplex = cmd->base.duplex;
1533 +- u32 speed = cmd->base.speed;
1534 +-
1535 +- if (cmd->base.phy_address != phydev->mdio.addr)
1536 +- return -EINVAL;
1537 +-
1538 +- linkmode_copy(advertising, cmd->link_modes.advertising);
1539 +-
1540 +- /* We make sure that we don't pass unsupported values in to the PHY */
1541 +- linkmode_and(advertising, advertising, phydev->supported);
1542 +-
1543 +- /* Verify the settings we care about. */
1544 +- if (autoneg != AUTONEG_ENABLE && autoneg != AUTONEG_DISABLE)
1545 +- return -EINVAL;
1546 +-
1547 +- if (autoneg == AUTONEG_ENABLE && linkmode_empty(advertising))
1548 +- return -EINVAL;
1549 +-
1550 +- if (autoneg == AUTONEG_DISABLE &&
1551 +- ((speed != SPEED_1000 &&
1552 +- speed != SPEED_100 &&
1553 +- speed != SPEED_10) ||
1554 +- (duplex != DUPLEX_HALF &&
1555 +- duplex != DUPLEX_FULL)))
1556 +- return -EINVAL;
1557 +-
1558 +- phydev->autoneg = autoneg;
1559 +-
1560 +- if (autoneg == AUTONEG_DISABLE) {
1561 +- phydev->speed = speed;
1562 +- phydev->duplex = duplex;
1563 +- }
1564 +-
1565 +- linkmode_copy(phydev->advertising, advertising);
1566 +-
1567 +- linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
1568 +- phydev->advertising, autoneg == AUTONEG_ENABLE);
1569 +-
1570 +- phydev->master_slave_set = cmd->base.master_slave_cfg;
1571 +- phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl;
1572 +-
1573 +- /* Restart the PHY */
1574 +- phy_start_aneg(phydev);
1575 +-
1576 +- return 0;
1577 +-}
1578 +-EXPORT_SYMBOL(phy_ethtool_ksettings_set);
1579 +-
1580 + void phy_ethtool_ksettings_get(struct phy_device *phydev,
1581 + struct ethtool_link_ksettings *cmd)
1582 + {
1583 ++ mutex_lock(&phydev->lock);
1584 + linkmode_copy(cmd->link_modes.supported, phydev->supported);
1585 + linkmode_copy(cmd->link_modes.advertising, phydev->advertising);
1586 + linkmode_copy(cmd->link_modes.lp_advertising, phydev->lp_advertising);
1587 +@@ -334,6 +282,7 @@ void phy_ethtool_ksettings_get(struct phy_device *phydev,
1588 + cmd->base.autoneg = phydev->autoneg;
1589 + cmd->base.eth_tp_mdix_ctrl = phydev->mdix_ctrl;
1590 + cmd->base.eth_tp_mdix = phydev->mdix;
1591 ++ mutex_unlock(&phydev->lock);
1592 + }
1593 + EXPORT_SYMBOL(phy_ethtool_ksettings_get);
1594 +
1595 +@@ -767,7 +716,7 @@ static int phy_check_link_status(struct phy_device *phydev)
1596 + }
1597 +
1598 + /**
1599 +- * phy_start_aneg - start auto-negotiation for this PHY device
1600 ++ * _phy_start_aneg - start auto-negotiation for this PHY device
1601 + * @phydev: the phy_device struct
1602 + *
1603 + * Description: Sanitizes the settings (if we're not autonegotiating
1604 +@@ -775,25 +724,43 @@ static int phy_check_link_status(struct phy_device *phydev)
1605 + * If the PHYCONTROL Layer is operating, we change the state to
1606 + * reflect the beginning of Auto-negotiation or forcing.
1607 + */
1608 +-int phy_start_aneg(struct phy_device *phydev)
1609 ++static int _phy_start_aneg(struct phy_device *phydev)
1610 + {
1611 + int err;
1612 +
1613 ++ lockdep_assert_held(&phydev->lock);
1614 ++
1615 + if (!phydev->drv)
1616 + return -EIO;
1617 +
1618 +- mutex_lock(&phydev->lock);
1619 +-
1620 + if (AUTONEG_DISABLE == phydev->autoneg)
1621 + phy_sanitize_settings(phydev);
1622 +
1623 + err = phy_config_aneg(phydev);
1624 + if (err < 0)
1625 +- goto out_unlock;
1626 ++ return err;
1627 +
1628 + if (phy_is_started(phydev))
1629 + err = phy_check_link_status(phydev);
1630 +-out_unlock:
1631 ++
1632 ++ return err;
1633 ++}
1634 ++
1635 ++/**
1636 ++ * phy_start_aneg - start auto-negotiation for this PHY device
1637 ++ * @phydev: the phy_device struct
1638 ++ *
1639 ++ * Description: Sanitizes the settings (if we're not autonegotiating
1640 ++ * them), and then calls the driver's config_aneg function.
1641 ++ * If the PHYCONTROL Layer is operating, we change the state to
1642 ++ * reflect the beginning of Auto-negotiation or forcing.
1643 ++ */
1644 ++int phy_start_aneg(struct phy_device *phydev)
1645 ++{
1646 ++ int err;
1647 ++
1648 ++ mutex_lock(&phydev->lock);
1649 ++ err = _phy_start_aneg(phydev);
1650 + mutex_unlock(&phydev->lock);
1651 +
1652 + return err;
1653 +@@ -816,6 +783,61 @@ static int phy_poll_aneg_done(struct phy_device *phydev)
1654 + return ret < 0 ? ret : 0;
1655 + }
1656 +
1657 ++int phy_ethtool_ksettings_set(struct phy_device *phydev,
1658 ++ const struct ethtool_link_ksettings *cmd)
1659 ++{
1660 ++ __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising);
1661 ++ u8 autoneg = cmd->base.autoneg;
1662 ++ u8 duplex = cmd->base.duplex;
1663 ++ u32 speed = cmd->base.speed;
1664 ++
1665 ++ if (cmd->base.phy_address != phydev->mdio.addr)
1666 ++ return -EINVAL;
1667 ++
1668 ++ linkmode_copy(advertising, cmd->link_modes.advertising);
1669 ++
1670 ++ /* We make sure that we don't pass unsupported values in to the PHY */
1671 ++ linkmode_and(advertising, advertising, phydev->supported);
1672 ++
1673 ++ /* Verify the settings we care about. */
1674 ++ if (autoneg != AUTONEG_ENABLE && autoneg != AUTONEG_DISABLE)
1675 ++ return -EINVAL;
1676 ++
1677 ++ if (autoneg == AUTONEG_ENABLE && linkmode_empty(advertising))
1678 ++ return -EINVAL;
1679 ++
1680 ++ if (autoneg == AUTONEG_DISABLE &&
1681 ++ ((speed != SPEED_1000 &&
1682 ++ speed != SPEED_100 &&
1683 ++ speed != SPEED_10) ||
1684 ++ (duplex != DUPLEX_HALF &&
1685 ++ duplex != DUPLEX_FULL)))
1686 ++ return -EINVAL;
1687 ++
1688 ++ mutex_lock(&phydev->lock);
1689 ++ phydev->autoneg = autoneg;
1690 ++
1691 ++ if (autoneg == AUTONEG_DISABLE) {
1692 ++ phydev->speed = speed;
1693 ++ phydev->duplex = duplex;
1694 ++ }
1695 ++
1696 ++ linkmode_copy(phydev->advertising, advertising);
1697 ++
1698 ++ linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
1699 ++ phydev->advertising, autoneg == AUTONEG_ENABLE);
1700 ++
1701 ++ phydev->master_slave_set = cmd->base.master_slave_cfg;
1702 ++ phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl;
1703 ++
1704 ++ /* Restart the PHY */
1705 ++ _phy_start_aneg(phydev);
1706 ++
1707 ++ mutex_unlock(&phydev->lock);
1708 ++ return 0;
1709 ++}
1710 ++EXPORT_SYMBOL(phy_ethtool_ksettings_set);
1711 ++
1712 + /**
1713 + * phy_speed_down - set speed to lowest speed supported by both link partners
1714 + * @phydev: the phy_device struct
1715 +diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
1716 +index a5cd42bae9621..a4f9912b36366 100644
1717 +--- a/drivers/net/usb/lan78xx.c
1718 ++++ b/drivers/net/usb/lan78xx.c
1719 +@@ -3745,6 +3745,12 @@ static int lan78xx_probe(struct usb_interface *intf,
1720 +
1721 + dev->maxpacket = usb_maxpacket(dev->udev, dev->pipe_out, 1);
1722 +
1723 ++ /* Reject broken descriptors. */
1724 ++ if (dev->maxpacket == 0) {
1725 ++ ret = -ENODEV;
1726 ++ goto out4;
1727 ++ }
1728 ++
1729 + /* driver requires remote-wakeup capability during autosuspend. */
1730 + intf->needs_remote_wakeup = 1;
1731 +
1732 +diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
1733 +index 6062dc27870e7..402390b1a66b5 100644
1734 +--- a/drivers/net/usb/usbnet.c
1735 ++++ b/drivers/net/usb/usbnet.c
1736 +@@ -1755,6 +1755,11 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1737 + if (!dev->rx_urb_size)
1738 + dev->rx_urb_size = dev->hard_mtu;
1739 + dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1);
1740 ++ if (dev->maxpacket == 0) {
1741 ++ /* that is a broken device */
1742 ++ status = -ENODEV;
1743 ++ goto out4;
1744 ++ }
1745 +
1746 + /* let userspace know we have a random address */
1747 + if (ether_addr_equal(net->dev_addr, node_id))
1748 +diff --git a/drivers/nfc/port100.c b/drivers/nfc/port100.c
1749 +index 8e4d355dc3aec..1caebefb25ff1 100644
1750 +--- a/drivers/nfc/port100.c
1751 ++++ b/drivers/nfc/port100.c
1752 +@@ -1003,11 +1003,11 @@ static u64 port100_get_command_type_mask(struct port100 *dev)
1753 +
1754 + skb = port100_alloc_skb(dev, 0);
1755 + if (!skb)
1756 +- return -ENOMEM;
1757 ++ return 0;
1758 +
1759 + resp = port100_send_cmd_sync(dev, PORT100_CMD_GET_COMMAND_TYPE, skb);
1760 + if (IS_ERR(resp))
1761 +- return PTR_ERR(resp);
1762 ++ return 0;
1763 +
1764 + if (resp->len < 8)
1765 + mask = 0;
1766 +diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
1767 +index 05ad6bee085c1..e99d439894187 100644
1768 +--- a/drivers/nvme/host/tcp.c
1769 ++++ b/drivers/nvme/host/tcp.c
1770 +@@ -910,12 +910,14 @@ static void nvme_tcp_fail_request(struct nvme_tcp_request *req)
1771 + static int nvme_tcp_try_send_data(struct nvme_tcp_request *req)
1772 + {
1773 + struct nvme_tcp_queue *queue = req->queue;
1774 ++ int req_data_len = req->data_len;
1775 +
1776 + while (true) {
1777 + struct page *page = nvme_tcp_req_cur_page(req);
1778 + size_t offset = nvme_tcp_req_cur_offset(req);
1779 + size_t len = nvme_tcp_req_cur_length(req);
1780 + bool last = nvme_tcp_pdu_last_send(req, len);
1781 ++ int req_data_sent = req->data_sent;
1782 + int ret, flags = MSG_DONTWAIT;
1783 +
1784 + if (last && !queue->data_digest && !nvme_tcp_queue_more(queue))
1785 +@@ -942,7 +944,7 @@ static int nvme_tcp_try_send_data(struct nvme_tcp_request *req)
1786 + * in the request where we don't want to modify it as we may
1787 + * compete with the RX path completing the request.
1788 + */
1789 +- if (req->data_sent + ret < req->data_len)
1790 ++ if (req_data_sent + ret < req_data_len)
1791 + nvme_tcp_advance_req(req, ret);
1792 +
1793 + /* fully successful last send in current PDU */
1794 +@@ -1035,10 +1037,11 @@ static int nvme_tcp_try_send_data_pdu(struct nvme_tcp_request *req)
1795 + static int nvme_tcp_try_send_ddgst(struct nvme_tcp_request *req)
1796 + {
1797 + struct nvme_tcp_queue *queue = req->queue;
1798 ++ size_t offset = req->offset;
1799 + int ret;
1800 + struct msghdr msg = { .msg_flags = MSG_DONTWAIT };
1801 + struct kvec iov = {
1802 +- .iov_base = &req->ddgst + req->offset,
1803 ++ .iov_base = (u8 *)&req->ddgst + req->offset,
1804 + .iov_len = NVME_TCP_DIGEST_LENGTH - req->offset
1805 + };
1806 +
1807 +@@ -1051,7 +1054,7 @@ static int nvme_tcp_try_send_ddgst(struct nvme_tcp_request *req)
1808 + if (unlikely(ret <= 0))
1809 + return ret;
1810 +
1811 +- if (req->offset + ret == NVME_TCP_DIGEST_LENGTH) {
1812 ++ if (offset + ret == NVME_TCP_DIGEST_LENGTH) {
1813 + nvme_tcp_done_send_req(queue);
1814 + return 1;
1815 + }
1816 +diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
1817 +index dedcb7aaf0d82..5266d534c4b31 100644
1818 +--- a/drivers/nvme/target/tcp.c
1819 ++++ b/drivers/nvme/target/tcp.c
1820 +@@ -690,7 +690,7 @@ static int nvmet_try_send_ddgst(struct nvmet_tcp_cmd *cmd, bool last_in_batch)
1821 + struct nvmet_tcp_queue *queue = cmd->queue;
1822 + struct msghdr msg = { .msg_flags = MSG_DONTWAIT };
1823 + struct kvec iov = {
1824 +- .iov_base = &cmd->exp_ddgst + cmd->offset,
1825 ++ .iov_base = (u8 *)&cmd->exp_ddgst + cmd->offset,
1826 + .iov_len = NVME_TCP_DIGEST_LENGTH - cmd->offset
1827 + };
1828 + int ret;
1829 +diff --git a/drivers/pinctrl/bcm/pinctrl-ns.c b/drivers/pinctrl/bcm/pinctrl-ns.c
1830 +index e79690bd8b85f..d7f8175d2c1c8 100644
1831 +--- a/drivers/pinctrl/bcm/pinctrl-ns.c
1832 ++++ b/drivers/pinctrl/bcm/pinctrl-ns.c
1833 +@@ -5,7 +5,6 @@
1834 +
1835 + #include <linux/err.h>
1836 + #include <linux/io.h>
1837 +-#include <linux/mfd/syscon.h>
1838 + #include <linux/module.h>
1839 + #include <linux/of.h>
1840 + #include <linux/of_device.h>
1841 +@@ -13,7 +12,6 @@
1842 + #include <linux/pinctrl/pinctrl.h>
1843 + #include <linux/pinctrl/pinmux.h>
1844 + #include <linux/platform_device.h>
1845 +-#include <linux/regmap.h>
1846 + #include <linux/slab.h>
1847 +
1848 + #define FLAG_BCM4708 BIT(1)
1849 +@@ -24,8 +22,7 @@ struct ns_pinctrl {
1850 + struct device *dev;
1851 + unsigned int chipset_flag;
1852 + struct pinctrl_dev *pctldev;
1853 +- struct regmap *regmap;
1854 +- u32 offset;
1855 ++ void __iomem *base;
1856 +
1857 + struct pinctrl_desc pctldesc;
1858 + struct ns_pinctrl_group *groups;
1859 +@@ -232,9 +229,9 @@ static int ns_pinctrl_set_mux(struct pinctrl_dev *pctrl_dev,
1860 + unset |= BIT(pin_number);
1861 + }
1862 +
1863 +- regmap_read(ns_pinctrl->regmap, ns_pinctrl->offset, &tmp);
1864 ++ tmp = readl(ns_pinctrl->base);
1865 + tmp &= ~unset;
1866 +- regmap_write(ns_pinctrl->regmap, ns_pinctrl->offset, tmp);
1867 ++ writel(tmp, ns_pinctrl->base);
1868 +
1869 + return 0;
1870 + }
1871 +@@ -266,13 +263,13 @@ static const struct of_device_id ns_pinctrl_of_match_table[] = {
1872 + static int ns_pinctrl_probe(struct platform_device *pdev)
1873 + {
1874 + struct device *dev = &pdev->dev;
1875 +- struct device_node *np = dev->of_node;
1876 + const struct of_device_id *of_id;
1877 + struct ns_pinctrl *ns_pinctrl;
1878 + struct pinctrl_desc *pctldesc;
1879 + struct pinctrl_pin_desc *pin;
1880 + struct ns_pinctrl_group *group;
1881 + struct ns_pinctrl_function *function;
1882 ++ struct resource *res;
1883 + int i;
1884 +
1885 + ns_pinctrl = devm_kzalloc(dev, sizeof(*ns_pinctrl), GFP_KERNEL);
1886 +@@ -290,18 +287,12 @@ static int ns_pinctrl_probe(struct platform_device *pdev)
1887 + return -EINVAL;
1888 + ns_pinctrl->chipset_flag = (uintptr_t)of_id->data;
1889 +
1890 +- ns_pinctrl->regmap = syscon_node_to_regmap(of_get_parent(np));
1891 +- if (IS_ERR(ns_pinctrl->regmap)) {
1892 +- int err = PTR_ERR(ns_pinctrl->regmap);
1893 +-
1894 +- dev_err(dev, "Failed to map pinctrl regs: %d\n", err);
1895 +-
1896 +- return err;
1897 +- }
1898 +-
1899 +- if (of_property_read_u32(np, "offset", &ns_pinctrl->offset)) {
1900 +- dev_err(dev, "Failed to get register offset\n");
1901 +- return -ENOENT;
1902 ++ res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
1903 ++ "cru_gpio_control");
1904 ++ ns_pinctrl->base = devm_ioremap_resource(dev, res);
1905 ++ if (IS_ERR(ns_pinctrl->base)) {
1906 ++ dev_err(dev, "Failed to map pinctrl regs\n");
1907 ++ return PTR_ERR(ns_pinctrl->base);
1908 + }
1909 +
1910 + memcpy(pctldesc, &ns_pinctrl_desc, sizeof(*pctldesc));
1911 +diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
1912 +index ef49402c0623d..e20bcc835d6a8 100644
1913 +--- a/drivers/pinctrl/pinctrl-amd.c
1914 ++++ b/drivers/pinctrl/pinctrl-amd.c
1915 +@@ -764,6 +764,34 @@ static const struct pinconf_ops amd_pinconf_ops = {
1916 + .pin_config_group_set = amd_pinconf_group_set,
1917 + };
1918 +
1919 ++static void amd_gpio_irq_init(struct amd_gpio *gpio_dev)
1920 ++{
1921 ++ struct pinctrl_desc *desc = gpio_dev->pctrl->desc;
1922 ++ unsigned long flags;
1923 ++ u32 pin_reg, mask;
1924 ++ int i;
1925 ++
1926 ++ mask = BIT(WAKE_CNTRL_OFF_S0I3) | BIT(WAKE_CNTRL_OFF_S3) |
1927 ++ BIT(INTERRUPT_MASK_OFF) | BIT(INTERRUPT_ENABLE_OFF) |
1928 ++ BIT(WAKE_CNTRL_OFF_S4);
1929 ++
1930 ++ for (i = 0; i < desc->npins; i++) {
1931 ++ int pin = desc->pins[i].number;
1932 ++ const struct pin_desc *pd = pin_desc_get(gpio_dev->pctrl, pin);
1933 ++
1934 ++ if (!pd)
1935 ++ continue;
1936 ++
1937 ++ raw_spin_lock_irqsave(&gpio_dev->lock, flags);
1938 ++
1939 ++ pin_reg = readl(gpio_dev->base + i * 4);
1940 ++ pin_reg &= ~mask;
1941 ++ writel(pin_reg, gpio_dev->base + i * 4);
1942 ++
1943 ++ raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
1944 ++ }
1945 ++}
1946 ++
1947 + #ifdef CONFIG_PM_SLEEP
1948 + static bool amd_gpio_should_save(struct amd_gpio *gpio_dev, unsigned int pin)
1949 + {
1950 +@@ -901,6 +929,9 @@ static int amd_gpio_probe(struct platform_device *pdev)
1951 + return PTR_ERR(gpio_dev->pctrl);
1952 + }
1953 +
1954 ++ /* Disable and mask interrupts */
1955 ++ amd_gpio_irq_init(gpio_dev);
1956 ++
1957 + girq = &gpio_dev->gc.irq;
1958 + girq->chip = &amd_gpio_irqchip;
1959 + /* This will let us handle the parent IRQ in the driver */
1960 +diff --git a/drivers/reset/reset-brcmstb-rescal.c b/drivers/reset/reset-brcmstb-rescal.c
1961 +index b6f074d6a65f8..433fa0c40e477 100644
1962 +--- a/drivers/reset/reset-brcmstb-rescal.c
1963 ++++ b/drivers/reset/reset-brcmstb-rescal.c
1964 +@@ -38,7 +38,7 @@ static int brcm_rescal_reset_set(struct reset_controller_dev *rcdev,
1965 + }
1966 +
1967 + ret = readl_poll_timeout(base + BRCM_RESCAL_STATUS, reg,
1968 +- !(reg & BRCM_RESCAL_STATUS_BIT), 100, 1000);
1969 ++ (reg & BRCM_RESCAL_STATUS_BIT), 100, 1000);
1970 + if (ret) {
1971 + dev_err(data->dev, "time out on SATA/PCIe rescal\n");
1972 + return ret;
1973 +diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c
1974 +index 3f4f3d6f48f9f..0246ea99df7b3 100644
1975 +--- a/drivers/scsi/ufs/ufs-exynos.c
1976 ++++ b/drivers/scsi/ufs/ufs-exynos.c
1977 +@@ -654,9 +654,9 @@ static int exynos_ufs_pre_pwr_mode(struct ufs_hba *hba,
1978 + }
1979 +
1980 + /* setting for three timeout values for traffic class #0 */
1981 +- ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA0), 8064);
1982 +- ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA1), 28224);
1983 +- ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA2), 20160);
1984 ++ ufshcd_dme_set(hba, UIC_ARG_MIB(DL_FC0PROTTIMEOUTVAL), 8064);
1985 ++ ufshcd_dme_set(hba, UIC_ARG_MIB(DL_TC0REPLAYTIMEOUTVAL), 28224);
1986 ++ ufshcd_dme_set(hba, UIC_ARG_MIB(DL_AFC0REQTIMEOUTVAL), 20160);
1987 +
1988 + return 0;
1989 + out:
1990 +diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
1991 +index 6cb598b549ca1..bc364c119af6a 100644
1992 +--- a/fs/ext4/mmp.c
1993 ++++ b/fs/ext4/mmp.c
1994 +@@ -156,7 +156,12 @@ static int kmmpd(void *data)
1995 + memcpy(mmp->mmp_nodename, init_utsname()->nodename,
1996 + sizeof(mmp->mmp_nodename));
1997 +
1998 +- while (!kthread_should_stop()) {
1999 ++ while (!kthread_should_stop() && !sb_rdonly(sb)) {
2000 ++ if (!ext4_has_feature_mmp(sb)) {
2001 ++ ext4_warning(sb, "kmmpd being stopped since MMP feature"
2002 ++ " has been disabled.");
2003 ++ goto wait_to_exit;
2004 ++ }
2005 + if (++seq > EXT4_MMP_SEQ_MAX)
2006 + seq = 1;
2007 +
2008 +@@ -177,16 +182,6 @@ static int kmmpd(void *data)
2009 + failed_writes++;
2010 + }
2011 +
2012 +- if (!(le32_to_cpu(es->s_feature_incompat) &
2013 +- EXT4_FEATURE_INCOMPAT_MMP)) {
2014 +- ext4_warning(sb, "kmmpd being stopped since MMP feature"
2015 +- " has been disabled.");
2016 +- goto exit_thread;
2017 +- }
2018 +-
2019 +- if (sb_rdonly(sb))
2020 +- break;
2021 +-
2022 + diff = jiffies - last_update_time;
2023 + if (diff < mmp_update_interval * HZ)
2024 + schedule_timeout_interruptible(mmp_update_interval *
2025 +@@ -207,7 +202,7 @@ static int kmmpd(void *data)
2026 + ext4_error_err(sb, -retval,
2027 + "error reading MMP data: %d",
2028 + retval);
2029 +- goto exit_thread;
2030 ++ goto wait_to_exit;
2031 + }
2032 +
2033 + mmp_check = (struct mmp_struct *)(bh_check->b_data);
2034 +@@ -221,7 +216,7 @@ static int kmmpd(void *data)
2035 + ext4_error_err(sb, EBUSY, "abort");
2036 + put_bh(bh_check);
2037 + retval = -EBUSY;
2038 +- goto exit_thread;
2039 ++ goto wait_to_exit;
2040 + }
2041 + put_bh(bh_check);
2042 + }
2043 +@@ -244,7 +239,13 @@ static int kmmpd(void *data)
2044 +
2045 + retval = write_mmp_block(sb, bh);
2046 +
2047 +-exit_thread:
2048 ++wait_to_exit:
2049 ++ while (!kthread_should_stop()) {
2050 ++ set_current_state(TASK_INTERRUPTIBLE);
2051 ++ if (!kthread_should_stop())
2052 ++ schedule();
2053 ++ }
2054 ++ set_current_state(TASK_RUNNING);
2055 + return retval;
2056 + }
2057 +
2058 +@@ -391,5 +392,3 @@ failed:
2059 + brelse(bh);
2060 + return 1;
2061 + }
2062 +-
2063 +-
2064 +diff --git a/fs/ext4/super.c b/fs/ext4/super.c
2065 +index cbeb024296719..953c7e8757831 100644
2066 +--- a/fs/ext4/super.c
2067 ++++ b/fs/ext4/super.c
2068 +@@ -5932,7 +5932,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
2069 + */
2070 + ext4_mark_recovery_complete(sb, es);
2071 + }
2072 +- ext4_stop_mmpd(sbi);
2073 + } else {
2074 + /* Make sure we can mount this feature set readwrite */
2075 + if (ext4_has_feature_readonly(sb) ||
2076 +@@ -6046,6 +6045,9 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
2077 + if (!test_opt(sb, BLOCK_VALIDITY) && sbi->s_system_blks)
2078 + ext4_release_system_zone(sb);
2079 +
2080 ++ if (!ext4_has_feature_mmp(sb) || sb_rdonly(sb))
2081 ++ ext4_stop_mmpd(sbi);
2082 ++
2083 + /*
2084 + * Some options can be enabled by ext4 and/or by VFS mount flag
2085 + * either way we need to make sure it matches in both *flags and
2086 +@@ -6078,6 +6080,8 @@ restore_opts:
2087 + for (i = 0; i < EXT4_MAXQUOTAS; i++)
2088 + kfree(to_free[i]);
2089 + #endif
2090 ++ if (!ext4_has_feature_mmp(sb) || sb_rdonly(sb))
2091 ++ ext4_stop_mmpd(sbi);
2092 + kfree(orig_data);
2093 + return err;
2094 + }
2095 +diff --git a/fs/io_uring.c b/fs/io_uring.c
2096 +index 0736487165da4..ee7ceea899346 100644
2097 +--- a/fs/io_uring.c
2098 ++++ b/fs/io_uring.c
2099 +@@ -2075,7 +2075,9 @@ static void io_req_task_cancel(struct callback_head *cb)
2100 + struct io_kiocb *req = container_of(cb, struct io_kiocb, task_work);
2101 + struct io_ring_ctx *ctx = req->ctx;
2102 +
2103 ++ mutex_lock(&ctx->uring_lock);
2104 + __io_req_task_cancel(req, -ECANCELED);
2105 ++ mutex_unlock(&ctx->uring_lock);
2106 + percpu_ref_put(&ctx->refs);
2107 + }
2108 +
2109 +diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
2110 +index 8c8cf7f4eb34e..e7d04adb6cb87 100644
2111 +--- a/fs/ocfs2/suballoc.c
2112 ++++ b/fs/ocfs2/suballoc.c
2113 +@@ -1253,7 +1253,7 @@ static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh,
2114 + {
2115 + struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;
2116 + struct journal_head *jh;
2117 +- int ret;
2118 ++ int ret = 1;
2119 +
2120 + if (ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap))
2121 + return 0;
2122 +@@ -1261,14 +1261,18 @@ static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh,
2123 + if (!buffer_jbd(bg_bh))
2124 + return 1;
2125 +
2126 +- jh = bh2jh(bg_bh);
2127 +- spin_lock(&jh->b_state_lock);
2128 +- bg = (struct ocfs2_group_desc *) jh->b_committed_data;
2129 +- if (bg)
2130 +- ret = !ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap);
2131 +- else
2132 +- ret = 1;
2133 +- spin_unlock(&jh->b_state_lock);
2134 ++ jbd_lock_bh_journal_head(bg_bh);
2135 ++ if (buffer_jbd(bg_bh)) {
2136 ++ jh = bh2jh(bg_bh);
2137 ++ spin_lock(&jh->b_state_lock);
2138 ++ bg = (struct ocfs2_group_desc *) jh->b_committed_data;
2139 ++ if (bg)
2140 ++ ret = !ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap);
2141 ++ else
2142 ++ ret = 1;
2143 ++ spin_unlock(&jh->b_state_lock);
2144 ++ }
2145 ++ jbd_unlock_bh_journal_head(bg_bh);
2146 +
2147 + return ret;
2148 + }
2149 +diff --git a/include/linux/bpf.h b/include/linux/bpf.h
2150 +index 0caa448f7b409..1f62a4eec283c 100644
2151 +--- a/include/linux/bpf.h
2152 ++++ b/include/linux/bpf.h
2153 +@@ -862,8 +862,11 @@ struct bpf_array_aux {
2154 + * stored in the map to make sure that all callers and callees have
2155 + * the same prog type and JITed flag.
2156 + */
2157 +- enum bpf_prog_type type;
2158 +- bool jited;
2159 ++ struct {
2160 ++ spinlock_t lock;
2161 ++ enum bpf_prog_type type;
2162 ++ bool jited;
2163 ++ } owner;
2164 + /* Programs with direct jumps into programs part of this array. */
2165 + struct list_head poke_progs;
2166 + struct bpf_map *map;
2167 +diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
2168 +index 8a1bf2dbadd0c..2a819be384a78 100644
2169 +--- a/include/net/cfg80211.h
2170 ++++ b/include/net/cfg80211.h
2171 +@@ -5202,7 +5202,6 @@ struct cfg80211_cqm_config;
2172 + * netdev and may otherwise be used by driver read-only, will be update
2173 + * by cfg80211 on change_interface
2174 + * @mgmt_registrations: list of registrations for management frames
2175 +- * @mgmt_registrations_lock: lock for the list
2176 + * @mgmt_registrations_need_update: mgmt registrations were updated,
2177 + * need to propagate the update to the driver
2178 + * @mtx: mutex used to lock data in this struct, may be used by drivers
2179 +@@ -5249,7 +5248,6 @@ struct wireless_dev {
2180 + u32 identifier;
2181 +
2182 + struct list_head mgmt_registrations;
2183 +- spinlock_t mgmt_registrations_lock;
2184 + u8 mgmt_registrations_need_update:1;
2185 +
2186 + struct mutex mtx;
2187 +diff --git a/include/net/tls.h b/include/net/tls.h
2188 +index 43891b28fc482..745b3bc6ce91d 100644
2189 +--- a/include/net/tls.h
2190 ++++ b/include/net/tls.h
2191 +@@ -359,6 +359,7 @@ int tls_sk_query(struct sock *sk, int optname, char __user *optval,
2192 + int __user *optlen);
2193 + int tls_sk_attach(struct sock *sk, int optname, char __user *optval,
2194 + unsigned int optlen);
2195 ++void tls_err_abort(struct sock *sk, int err);
2196 +
2197 + int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx);
2198 + void tls_sw_strparser_arm(struct sock *sk, struct tls_context *ctx);
2199 +@@ -467,12 +468,6 @@ static inline bool tls_is_sk_tx_device_offloaded(struct sock *sk)
2200 + #endif
2201 + }
2202 +
2203 +-static inline void tls_err_abort(struct sock *sk, int err)
2204 +-{
2205 +- sk->sk_err = err;
2206 +- sk->sk_error_report(sk);
2207 +-}
2208 +-
2209 + static inline bool tls_bigint_increment(unsigned char *seq, int len)
2210 + {
2211 + int i;
2212 +@@ -513,7 +508,7 @@ static inline void tls_advance_record_sn(struct sock *sk,
2213 + struct cipher_context *ctx)
2214 + {
2215 + if (tls_bigint_increment(ctx->rec_seq, prot->rec_seq_size))
2216 +- tls_err_abort(sk, EBADMSG);
2217 ++ tls_err_abort(sk, -EBADMSG);
2218 +
2219 + if (prot->version != TLS_1_3_VERSION)
2220 + tls_bigint_increment(ctx->iv + TLS_CIPHER_AES_GCM_128_SALT_SIZE,
2221 +diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
2222 +index c6c81eceb68fb..36c68dcea2369 100644
2223 +--- a/kernel/bpf/arraymap.c
2224 ++++ b/kernel/bpf/arraymap.c
2225 +@@ -1025,6 +1025,7 @@ static struct bpf_map *prog_array_map_alloc(union bpf_attr *attr)
2226 + INIT_WORK(&aux->work, prog_array_map_clear_deferred);
2227 + INIT_LIST_HEAD(&aux->poke_progs);
2228 + mutex_init(&aux->poke_mutex);
2229 ++ spin_lock_init(&aux->owner.lock);
2230 +
2231 + map = array_map_alloc(attr);
2232 + if (IS_ERR(map)) {
2233 +diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
2234 +index 2e4a658d65d6e..72e4bf0ee5460 100644
2235 +--- a/kernel/bpf/core.c
2236 ++++ b/kernel/bpf/core.c
2237 +@@ -1775,20 +1775,26 @@ static unsigned int __bpf_prog_ret0_warn(const void *ctx,
2238 + bool bpf_prog_array_compatible(struct bpf_array *array,
2239 + const struct bpf_prog *fp)
2240 + {
2241 ++ bool ret;
2242 ++
2243 + if (fp->kprobe_override)
2244 + return false;
2245 +
2246 +- if (!array->aux->type) {
2247 ++ spin_lock(&array->aux->owner.lock);
2248 ++
2249 ++ if (!array->aux->owner.type) {
2250 + /* There's no owner yet where we could check for
2251 + * compatibility.
2252 + */
2253 +- array->aux->type = fp->type;
2254 +- array->aux->jited = fp->jited;
2255 +- return true;
2256 ++ array->aux->owner.type = fp->type;
2257 ++ array->aux->owner.jited = fp->jited;
2258 ++ ret = true;
2259 ++ } else {
2260 ++ ret = array->aux->owner.type == fp->type &&
2261 ++ array->aux->owner.jited == fp->jited;
2262 + }
2263 +-
2264 +- return array->aux->type == fp->type &&
2265 +- array->aux->jited == fp->jited;
2266 ++ spin_unlock(&array->aux->owner.lock);
2267 ++ return ret;
2268 + }
2269 +
2270 + static int bpf_check_tail_call(const struct bpf_prog *fp)
2271 +diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
2272 +index 9433ab9995cd7..5b6da64da46d7 100644
2273 +--- a/kernel/bpf/syscall.c
2274 ++++ b/kernel/bpf/syscall.c
2275 +@@ -535,8 +535,10 @@ static void bpf_map_show_fdinfo(struct seq_file *m, struct file *filp)
2276 +
2277 + if (map->map_type == BPF_MAP_TYPE_PROG_ARRAY) {
2278 + array = container_of(map, struct bpf_array, map);
2279 +- type = array->aux->type;
2280 +- jited = array->aux->jited;
2281 ++ spin_lock(&array->aux->owner.lock);
2282 ++ type = array->aux->owner.type;
2283 ++ jited = array->aux->owner.jited;
2284 ++ spin_unlock(&array->aux->owner.lock);
2285 + }
2286 +
2287 + seq_printf(m,
2288 +@@ -1307,12 +1309,11 @@ int generic_map_update_batch(struct bpf_map *map,
2289 + void __user *values = u64_to_user_ptr(attr->batch.values);
2290 + void __user *keys = u64_to_user_ptr(attr->batch.keys);
2291 + u32 value_size, cp, max_count;
2292 +- int ufd = attr->map_fd;
2293 ++ int ufd = attr->batch.map_fd;
2294 + void *key, *value;
2295 + struct fd f;
2296 + int err = 0;
2297 +
2298 +- f = fdget(ufd);
2299 + if (attr->batch.elem_flags & ~BPF_F_LOCK)
2300 + return -EINVAL;
2301 +
2302 +@@ -1337,6 +1338,7 @@ int generic_map_update_batch(struct bpf_map *map,
2303 + return -ENOMEM;
2304 + }
2305 +
2306 ++ f = fdget(ufd); /* bpf_map_do_batch() guarantees ufd is valid */
2307 + for (cp = 0; cp < max_count; cp++) {
2308 + err = -EFAULT;
2309 + if (copy_from_user(key, keys + cp * map->key_size,
2310 +@@ -1356,6 +1358,7 @@ int generic_map_update_batch(struct bpf_map *map,
2311 +
2312 + kfree(value);
2313 + kfree(key);
2314 ++ fdput(f);
2315 + return err;
2316 + }
2317 +
2318 +diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
2319 +index c8b811e039cc2..60d38e2f69dd8 100644
2320 +--- a/kernel/cgroup/cgroup.c
2321 ++++ b/kernel/cgroup/cgroup.c
2322 +@@ -2147,8 +2147,10 @@ static void cgroup_kill_sb(struct super_block *sb)
2323 + * And don't kill the default root.
2324 + */
2325 + if (list_empty(&root->cgrp.self.children) && root != &cgrp_dfl_root &&
2326 +- !percpu_ref_is_dying(&root->cgrp.self.refcnt))
2327 ++ !percpu_ref_is_dying(&root->cgrp.self.refcnt)) {
2328 ++ cgroup_bpf_offline(&root->cgrp);
2329 + percpu_ref_kill(&root->cgrp.self.refcnt);
2330 ++ }
2331 + cgroup_put(&root->cgrp);
2332 + kernfs_kill_sb(sb);
2333 + }
2334 +diff --git a/mm/khugepaged.c b/mm/khugepaged.c
2335 +index ee88125785638..ff389d970b683 100644
2336 +--- a/mm/khugepaged.c
2337 ++++ b/mm/khugepaged.c
2338 +@@ -1758,6 +1758,10 @@ static void collapse_file(struct mm_struct *mm,
2339 + filemap_flush(mapping);
2340 + result = SCAN_FAIL;
2341 + goto xa_unlocked;
2342 ++ } else if (PageWriteback(page)) {
2343 ++ xas_unlock_irq(&xas);
2344 ++ result = SCAN_FAIL;
2345 ++ goto xa_unlocked;
2346 + } else if (trylock_page(page)) {
2347 + get_page(page);
2348 + xas_unlock_irq(&xas);
2349 +@@ -1793,7 +1797,8 @@ static void collapse_file(struct mm_struct *mm,
2350 + goto out_unlock;
2351 + }
2352 +
2353 +- if (!is_shmem && PageDirty(page)) {
2354 ++ if (!is_shmem && (PageDirty(page) ||
2355 ++ PageWriteback(page))) {
2356 + /*
2357 + * khugepaged only works on read-only fd, so this
2358 + * page is dirty because it hasn't been flushed
2359 +diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
2360 +index ba0027d1f2dfd..ee9cead765450 100644
2361 +--- a/net/batman-adv/bridge_loop_avoidance.c
2362 ++++ b/net/batman-adv/bridge_loop_avoidance.c
2363 +@@ -1561,10 +1561,14 @@ int batadv_bla_init(struct batadv_priv *bat_priv)
2364 + return 0;
2365 +
2366 + bat_priv->bla.claim_hash = batadv_hash_new(128);
2367 +- bat_priv->bla.backbone_hash = batadv_hash_new(32);
2368 ++ if (!bat_priv->bla.claim_hash)
2369 ++ return -ENOMEM;
2370 +
2371 +- if (!bat_priv->bla.claim_hash || !bat_priv->bla.backbone_hash)
2372 ++ bat_priv->bla.backbone_hash = batadv_hash_new(32);
2373 ++ if (!bat_priv->bla.backbone_hash) {
2374 ++ batadv_hash_destroy(bat_priv->bla.claim_hash);
2375 + return -ENOMEM;
2376 ++ }
2377 +
2378 + batadv_hash_set_lock_class(bat_priv->bla.claim_hash,
2379 + &batadv_claim_hash_lock_class_key);
2380 +diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
2381 +index 70fee9b42e25f..9f267b190779f 100644
2382 +--- a/net/batman-adv/main.c
2383 ++++ b/net/batman-adv/main.c
2384 +@@ -196,29 +196,41 @@ int batadv_mesh_init(struct net_device *soft_iface)
2385 +
2386 + bat_priv->gw.generation = 0;
2387 +
2388 +- ret = batadv_v_mesh_init(bat_priv);
2389 +- if (ret < 0)
2390 +- goto err;
2391 +-
2392 + ret = batadv_originator_init(bat_priv);
2393 +- if (ret < 0)
2394 +- goto err;
2395 ++ if (ret < 0) {
2396 ++ atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
2397 ++ goto err_orig;
2398 ++ }
2399 +
2400 + ret = batadv_tt_init(bat_priv);
2401 +- if (ret < 0)
2402 +- goto err;
2403 ++ if (ret < 0) {
2404 ++ atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
2405 ++ goto err_tt;
2406 ++ }
2407 ++
2408 ++ ret = batadv_v_mesh_init(bat_priv);
2409 ++ if (ret < 0) {
2410 ++ atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
2411 ++ goto err_v;
2412 ++ }
2413 +
2414 + ret = batadv_bla_init(bat_priv);
2415 +- if (ret < 0)
2416 +- goto err;
2417 ++ if (ret < 0) {
2418 ++ atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
2419 ++ goto err_bla;
2420 ++ }
2421 +
2422 + ret = batadv_dat_init(bat_priv);
2423 +- if (ret < 0)
2424 +- goto err;
2425 ++ if (ret < 0) {
2426 ++ atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
2427 ++ goto err_dat;
2428 ++ }
2429 +
2430 + ret = batadv_nc_mesh_init(bat_priv);
2431 +- if (ret < 0)
2432 +- goto err;
2433 ++ if (ret < 0) {
2434 ++ atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
2435 ++ goto err_nc;
2436 ++ }
2437 +
2438 + batadv_gw_init(bat_priv);
2439 + batadv_mcast_init(bat_priv);
2440 +@@ -228,8 +240,20 @@ int batadv_mesh_init(struct net_device *soft_iface)
2441 +
2442 + return 0;
2443 +
2444 +-err:
2445 +- batadv_mesh_free(soft_iface);
2446 ++err_nc:
2447 ++ batadv_dat_free(bat_priv);
2448 ++err_dat:
2449 ++ batadv_bla_free(bat_priv);
2450 ++err_bla:
2451 ++ batadv_v_mesh_free(bat_priv);
2452 ++err_v:
2453 ++ batadv_tt_free(bat_priv);
2454 ++err_tt:
2455 ++ batadv_originator_free(bat_priv);
2456 ++err_orig:
2457 ++ batadv_purge_outstanding_packets(bat_priv, NULL);
2458 ++ atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
2459 ++
2460 + return ret;
2461 + }
2462 +
2463 +diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c
2464 +index 61ddd6d709a0e..35b3e03c07774 100644
2465 +--- a/net/batman-adv/network-coding.c
2466 ++++ b/net/batman-adv/network-coding.c
2467 +@@ -155,8 +155,10 @@ int batadv_nc_mesh_init(struct batadv_priv *bat_priv)
2468 + &batadv_nc_coding_hash_lock_class_key);
2469 +
2470 + bat_priv->nc.decoding_hash = batadv_hash_new(128);
2471 +- if (!bat_priv->nc.decoding_hash)
2472 ++ if (!bat_priv->nc.decoding_hash) {
2473 ++ batadv_hash_destroy(bat_priv->nc.coding_hash);
2474 + goto err;
2475 ++ }
2476 +
2477 + batadv_hash_set_lock_class(bat_priv->nc.decoding_hash,
2478 + &batadv_nc_decoding_hash_lock_class_key);
2479 +diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
2480 +index a510f7f86a7dc..de946ea8f13c8 100644
2481 +--- a/net/batman-adv/translation-table.c
2482 ++++ b/net/batman-adv/translation-table.c
2483 +@@ -4405,8 +4405,10 @@ int batadv_tt_init(struct batadv_priv *bat_priv)
2484 + return ret;
2485 +
2486 + ret = batadv_tt_global_init(bat_priv);
2487 +- if (ret < 0)
2488 ++ if (ret < 0) {
2489 ++ batadv_tt_local_table_free(bat_priv);
2490 + return ret;
2491 ++ }
2492 +
2493 + batadv_tvlv_handler_register(bat_priv, batadv_tt_tvlv_ogm_handler_v1,
2494 + batadv_tt_tvlv_unicast_handler_v1,
2495 +diff --git a/net/core/dev.c b/net/core/dev.c
2496 +index b9d19fbb15890..6a4e0e3c59fec 100644
2497 +--- a/net/core/dev.c
2498 ++++ b/net/core/dev.c
2499 +@@ -3171,6 +3171,12 @@ static u16 skb_tx_hash(const struct net_device *dev,
2500 +
2501 + qoffset = sb_dev->tc_to_txq[tc].offset;
2502 + qcount = sb_dev->tc_to_txq[tc].count;
2503 ++ if (unlikely(!qcount)) {
2504 ++ net_warn_ratelimited("%s: invalid qcount, qoffset %u for tc %u\n",
2505 ++ sb_dev->name, qoffset, tc);
2506 ++ qoffset = 0;
2507 ++ qcount = dev->real_num_tx_queues;
2508 ++ }
2509 + }
2510 +
2511 + if (skb_rx_queue_recorded(skb)) {
2512 +diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
2513 +index b4562f9d074cf..cc5f760c78250 100644
2514 +--- a/net/core/net-sysfs.c
2515 ++++ b/net/core/net-sysfs.c
2516 +@@ -1957,9 +1957,9 @@ int netdev_register_kobject(struct net_device *ndev)
2517 + int netdev_change_owner(struct net_device *ndev, const struct net *net_old,
2518 + const struct net *net_new)
2519 + {
2520 ++ kuid_t old_uid = GLOBAL_ROOT_UID, new_uid = GLOBAL_ROOT_UID;
2521 ++ kgid_t old_gid = GLOBAL_ROOT_GID, new_gid = GLOBAL_ROOT_GID;
2522 + struct device *dev = &ndev->dev;
2523 +- kuid_t old_uid, new_uid;
2524 +- kgid_t old_gid, new_gid;
2525 + int error;
2526 +
2527 + net_ns_get_ownership(net_old, &old_uid, &old_gid);
2528 +diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
2529 +index f91ae827d47f5..9194070c67250 100644
2530 +--- a/net/ipv4/tcp_bpf.c
2531 ++++ b/net/ipv4/tcp_bpf.c
2532 +@@ -317,6 +317,7 @@ static int tcp_bpf_send_verdict(struct sock *sk, struct sk_psock *psock,
2533 + bool cork = false, enospc = sk_msg_full(msg);
2534 + struct sock *sk_redir;
2535 + u32 tosend, delta = 0;
2536 ++ u32 eval = __SK_NONE;
2537 + int ret;
2538 +
2539 + more_data:
2540 +@@ -360,13 +361,24 @@ more_data:
2541 + case __SK_REDIRECT:
2542 + sk_redir = psock->sk_redir;
2543 + sk_msg_apply_bytes(psock, tosend);
2544 ++ if (!psock->apply_bytes) {
2545 ++ /* Clean up before releasing the sock lock. */
2546 ++ eval = psock->eval;
2547 ++ psock->eval = __SK_NONE;
2548 ++ psock->sk_redir = NULL;
2549 ++ }
2550 + if (psock->cork) {
2551 + cork = true;
2552 + psock->cork = NULL;
2553 + }
2554 + sk_msg_return(sk, msg, tosend);
2555 + release_sock(sk);
2556 ++
2557 + ret = tcp_bpf_sendmsg_redir(sk_redir, msg, tosend, flags);
2558 ++
2559 ++ if (eval == __SK_REDIRECT)
2560 ++ sock_put(sk_redir);
2561 ++
2562 + lock_sock(sk);
2563 + if (unlikely(ret < 0)) {
2564 + int free = sk_msg_free_nocharge(sk, msg);
2565 +diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
2566 +index b65bdaa84228f..096e6be1d8fc8 100644
2567 +--- a/net/sctp/sm_statefuns.c
2568 ++++ b/net/sctp/sm_statefuns.c
2569 +@@ -697,6 +697,9 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net,
2570 + struct sock *sk;
2571 + int error = 0;
2572 +
2573 ++ if (asoc && !sctp_vtag_verify(chunk, asoc))
2574 ++ return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
2575 ++
2576 + /* If the packet is an OOTB packet which is temporarily on the
2577 + * control endpoint, respond with an ABORT.
2578 + */
2579 +@@ -711,7 +714,8 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net,
2580 + * in sctp_unpack_cookie().
2581 + */
2582 + if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr)))
2583 +- return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
2584 ++ return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
2585 ++ commands);
2586 +
2587 + /* If the endpoint is not listening or if the number of associations
2588 + * on the TCP-style socket exceed the max backlog, respond with an
2589 +@@ -2141,9 +2145,11 @@ enum sctp_disposition sctp_sf_do_5_2_4_dupcook(
2590 + * enough for the chunk header. Cookie length verification is
2591 + * done later.
2592 + */
2593 +- if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr)))
2594 +- return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
2595 +- commands);
2596 ++ if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr))) {
2597 ++ if (!sctp_vtag_verify(chunk, asoc))
2598 ++ asoc = NULL;
2599 ++ return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, commands);
2600 ++ }
2601 +
2602 + /* "Decode" the chunk. We have no optional parameters so we
2603 + * are in good shape.
2604 +@@ -2280,7 +2286,7 @@ enum sctp_disposition sctp_sf_shutdown_pending_abort(
2605 + */
2606 + if (SCTP_ADDR_DEL ==
2607 + sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest))
2608 +- return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands);
2609 ++ return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
2610 +
2611 + if (!sctp_err_chunk_valid(chunk))
2612 + return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
2613 +@@ -2326,7 +2332,7 @@ enum sctp_disposition sctp_sf_shutdown_sent_abort(
2614 + */
2615 + if (SCTP_ADDR_DEL ==
2616 + sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest))
2617 +- return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands);
2618 ++ return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
2619 +
2620 + if (!sctp_err_chunk_valid(chunk))
2621 + return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
2622 +@@ -2596,7 +2602,7 @@ enum sctp_disposition sctp_sf_do_9_1_abort(
2623 + */
2624 + if (SCTP_ADDR_DEL ==
2625 + sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest))
2626 +- return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands);
2627 ++ return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
2628 +
2629 + if (!sctp_err_chunk_valid(chunk))
2630 + return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
2631 +@@ -3562,6 +3568,9 @@ enum sctp_disposition sctp_sf_ootb(struct net *net,
2632 +
2633 + SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES);
2634 +
2635 ++ if (asoc && !sctp_vtag_verify(chunk, asoc))
2636 ++ asoc = NULL;
2637 ++
2638 + ch = (struct sctp_chunkhdr *)chunk->chunk_hdr;
2639 + do {
2640 + /* Report violation if the chunk is less then minimal */
2641 +@@ -3677,12 +3686,6 @@ static enum sctp_disposition sctp_sf_shut_8_4_5(
2642 +
2643 + SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS);
2644 +
2645 +- /* If the chunk length is invalid, we don't want to process
2646 +- * the reset of the packet.
2647 +- */
2648 +- if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr)))
2649 +- return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
2650 +-
2651 + /* We need to discard the rest of the packet to prevent
2652 + * potential bomming attacks from additional bundled chunks.
2653 + * This is documented in SCTP Threats ID.
2654 +@@ -3710,6 +3713,9 @@ enum sctp_disposition sctp_sf_do_8_5_1_E_sa(struct net *net,
2655 + {
2656 + struct sctp_chunk *chunk = arg;
2657 +
2658 ++ if (!sctp_vtag_verify(chunk, asoc))
2659 ++ asoc = NULL;
2660 ++
2661 + /* Make sure that the SHUTDOWN_ACK chunk has a valid length. */
2662 + if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr)))
2663 + return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
2664 +@@ -3745,6 +3751,11 @@ enum sctp_disposition sctp_sf_do_asconf(struct net *net,
2665 + return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
2666 + }
2667 +
2668 ++ /* Make sure that the ASCONF ADDIP chunk has a valid length. */
2669 ++ if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_addip_chunk)))
2670 ++ return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
2671 ++ commands);
2672 ++
2673 + /* ADD-IP: Section 4.1.1
2674 + * This chunk MUST be sent in an authenticated way by using
2675 + * the mechanism defined in [I-D.ietf-tsvwg-sctp-auth]. If this chunk
2676 +@@ -3753,13 +3764,7 @@ enum sctp_disposition sctp_sf_do_asconf(struct net *net,
2677 + */
2678 + if (!asoc->peer.asconf_capable ||
2679 + (!net->sctp.addip_noauth && !chunk->auth))
2680 +- return sctp_sf_discard_chunk(net, ep, asoc, type, arg,
2681 +- commands);
2682 +-
2683 +- /* Make sure that the ASCONF ADDIP chunk has a valid length. */
2684 +- if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_addip_chunk)))
2685 +- return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
2686 +- commands);
2687 ++ return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
2688 +
2689 + hdr = (struct sctp_addiphdr *)chunk->skb->data;
2690 + serial = ntohl(hdr->serial);
2691 +@@ -3888,6 +3893,12 @@ enum sctp_disposition sctp_sf_do_asconf_ack(struct net *net,
2692 + return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
2693 + }
2694 +
2695 ++ /* Make sure that the ADDIP chunk has a valid length. */
2696 ++ if (!sctp_chunk_length_valid(asconf_ack,
2697 ++ sizeof(struct sctp_addip_chunk)))
2698 ++ return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
2699 ++ commands);
2700 ++
2701 + /* ADD-IP, Section 4.1.2:
2702 + * This chunk MUST be sent in an authenticated way by using
2703 + * the mechanism defined in [I-D.ietf-tsvwg-sctp-auth]. If this chunk
2704 +@@ -3896,14 +3907,7 @@ enum sctp_disposition sctp_sf_do_asconf_ack(struct net *net,
2705 + */
2706 + if (!asoc->peer.asconf_capable ||
2707 + (!net->sctp.addip_noauth && !asconf_ack->auth))
2708 +- return sctp_sf_discard_chunk(net, ep, asoc, type, arg,
2709 +- commands);
2710 +-
2711 +- /* Make sure that the ADDIP chunk has a valid length. */
2712 +- if (!sctp_chunk_length_valid(asconf_ack,
2713 +- sizeof(struct sctp_addip_chunk)))
2714 +- return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
2715 +- commands);
2716 ++ return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
2717 +
2718 + addip_hdr = (struct sctp_addiphdr *)asconf_ack->skb->data;
2719 + rcvd_serial = ntohl(addip_hdr->serial);
2720 +@@ -4475,6 +4479,9 @@ enum sctp_disposition sctp_sf_discard_chunk(struct net *net,
2721 + {
2722 + struct sctp_chunk *chunk = arg;
2723 +
2724 ++ if (asoc && !sctp_vtag_verify(chunk, asoc))
2725 ++ return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
2726 ++
2727 + /* Make sure that the chunk has a valid length.
2728 + * Since we don't know the chunk type, we use a general
2729 + * chunkhdr structure to make a comparison.
2730 +@@ -4542,6 +4549,9 @@ enum sctp_disposition sctp_sf_violation(struct net *net,
2731 + {
2732 + struct sctp_chunk *chunk = arg;
2733 +
2734 ++ if (!sctp_vtag_verify(chunk, asoc))
2735 ++ return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
2736 ++
2737 + /* Make sure that the chunk has a valid length. */
2738 + if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr)))
2739 + return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
2740 +@@ -6248,6 +6258,7 @@ static struct sctp_packet *sctp_ootb_pkt_new(
2741 + * yet.
2742 + */
2743 + switch (chunk->chunk_hdr->type) {
2744 ++ case SCTP_CID_INIT:
2745 + case SCTP_CID_INIT_ACK:
2746 + {
2747 + struct sctp_initack_chunk *initack;
2748 +diff --git a/net/tipc/crypto.c b/net/tipc/crypto.c
2749 +index f8e73c4a00933..23b100f36ee48 100644
2750 +--- a/net/tipc/crypto.c
2751 ++++ b/net/tipc/crypto.c
2752 +@@ -2278,43 +2278,53 @@ static bool tipc_crypto_key_rcv(struct tipc_crypto *rx, struct tipc_msg *hdr)
2753 + u16 key_gen = msg_key_gen(hdr);
2754 + u16 size = msg_data_sz(hdr);
2755 + u8 *data = msg_data(hdr);
2756 ++ unsigned int keylen;
2757 ++
2758 ++ /* Verify whether the size can exist in the packet */
2759 ++ if (unlikely(size < sizeof(struct tipc_aead_key) + TIPC_AEAD_KEYLEN_MIN)) {
2760 ++ pr_debug("%s: message data size is too small\n", rx->name);
2761 ++ goto exit;
2762 ++ }
2763 ++
2764 ++ keylen = ntohl(*((__be32 *)(data + TIPC_AEAD_ALG_NAME)));
2765 ++
2766 ++ /* Verify the supplied size values */
2767 ++ if (unlikely(size != keylen + sizeof(struct tipc_aead_key) ||
2768 ++ keylen > TIPC_AEAD_KEY_SIZE_MAX)) {
2769 ++ pr_debug("%s: invalid MSG_CRYPTO key size\n", rx->name);
2770 ++ goto exit;
2771 ++ }
2772 +
2773 + spin_lock(&rx->lock);
2774 + if (unlikely(rx->skey || (key_gen == rx->key_gen && rx->key.keys))) {
2775 + pr_err("%s: key existed <%p>, gen %d vs %d\n", rx->name,
2776 + rx->skey, key_gen, rx->key_gen);
2777 +- goto exit;
2778 ++ goto exit_unlock;
2779 + }
2780 +
2781 + /* Allocate memory for the key */
2782 + skey = kmalloc(size, GFP_ATOMIC);
2783 + if (unlikely(!skey)) {
2784 + pr_err("%s: unable to allocate memory for skey\n", rx->name);
2785 +- goto exit;
2786 ++ goto exit_unlock;
2787 + }
2788 +
2789 + /* Copy key from msg data */
2790 +- skey->keylen = ntohl(*((__be32 *)(data + TIPC_AEAD_ALG_NAME)));
2791 ++ skey->keylen = keylen;
2792 + memcpy(skey->alg_name, data, TIPC_AEAD_ALG_NAME);
2793 + memcpy(skey->key, data + TIPC_AEAD_ALG_NAME + sizeof(__be32),
2794 + skey->keylen);
2795 +
2796 +- /* Sanity check */
2797 +- if (unlikely(size != tipc_aead_key_size(skey))) {
2798 +- kfree(skey);
2799 +- skey = NULL;
2800 +- goto exit;
2801 +- }
2802 +-
2803 + rx->key_gen = key_gen;
2804 + rx->skey_mode = msg_key_mode(hdr);
2805 + rx->skey = skey;
2806 + rx->nokey = 0;
2807 + mb(); /* for nokey flag */
2808 +
2809 +-exit:
2810 ++exit_unlock:
2811 + spin_unlock(&rx->lock);
2812 +
2813 ++exit:
2814 + /* Schedule the key attaching on this crypto */
2815 + if (likely(skey && queue_delayed_work(tx->wq, &rx->work, 0)))
2816 + return true;
2817 +diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
2818 +index 15395683b8e2a..14cce61160a58 100644
2819 +--- a/net/tls/tls_sw.c
2820 ++++ b/net/tls/tls_sw.c
2821 +@@ -35,6 +35,7 @@
2822 + * SOFTWARE.
2823 + */
2824 +
2825 ++#include <linux/bug.h>
2826 + #include <linux/sched/signal.h>
2827 + #include <linux/module.h>
2828 + #include <linux/splice.h>
2829 +@@ -43,6 +44,14 @@
2830 + #include <net/strparser.h>
2831 + #include <net/tls.h>
2832 +
2833 ++noinline void tls_err_abort(struct sock *sk, int err)
2834 ++{
2835 ++ WARN_ON_ONCE(err >= 0);
2836 ++ /* sk->sk_err should contain a positive error code. */
2837 ++ sk->sk_err = -err;
2838 ++ sk->sk_error_report(sk);
2839 ++}
2840 ++
2841 + static int __skb_nsg(struct sk_buff *skb, int offset, int len,
2842 + unsigned int recursion_level)
2843 + {
2844 +@@ -419,7 +428,7 @@ int tls_tx_records(struct sock *sk, int flags)
2845 +
2846 + tx_err:
2847 + if (rc < 0 && rc != -EAGAIN)
2848 +- tls_err_abort(sk, EBADMSG);
2849 ++ tls_err_abort(sk, -EBADMSG);
2850 +
2851 + return rc;
2852 + }
2853 +@@ -450,7 +459,7 @@ static void tls_encrypt_done(struct crypto_async_request *req, int err)
2854 +
2855 + /* If err is already set on socket, return the same code */
2856 + if (sk->sk_err) {
2857 +- ctx->async_wait.err = sk->sk_err;
2858 ++ ctx->async_wait.err = -sk->sk_err;
2859 + } else {
2860 + ctx->async_wait.err = err;
2861 + tls_err_abort(sk, err);
2862 +@@ -764,7 +773,7 @@ static int tls_push_record(struct sock *sk, int flags,
2863 + msg_pl->sg.size + prot->tail_size, i);
2864 + if (rc < 0) {
2865 + if (rc != -EINPROGRESS) {
2866 +- tls_err_abort(sk, EBADMSG);
2867 ++ tls_err_abort(sk, -EBADMSG);
2868 + if (split) {
2869 + tls_ctx->pending_open_record_frags = true;
2870 + tls_merge_open_record(sk, rec, tmp, orig_end);
2871 +@@ -1828,7 +1837,7 @@ int tls_sw_recvmsg(struct sock *sk,
2872 + err = decrypt_skb_update(sk, skb, &msg->msg_iter,
2873 + &chunk, &zc, async_capable);
2874 + if (err < 0 && err != -EINPROGRESS) {
2875 +- tls_err_abort(sk, EBADMSG);
2876 ++ tls_err_abort(sk, -EBADMSG);
2877 + goto recv_end;
2878 + }
2879 +
2880 +@@ -2008,7 +2017,7 @@ ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos,
2881 + }
2882 +
2883 + if (err < 0) {
2884 +- tls_err_abort(sk, EBADMSG);
2885 ++ tls_err_abort(sk, -EBADMSG);
2886 + goto splice_read_end;
2887 + }
2888 + ctx->decrypted = 1;
2889 +diff --git a/net/wireless/core.c b/net/wireless/core.c
2890 +index 240282c083aa7..3f4554723761d 100644
2891 +--- a/net/wireless/core.c
2892 ++++ b/net/wireless/core.c
2893 +@@ -501,6 +501,7 @@ use_default_name:
2894 + INIT_WORK(&rdev->propagate_cac_done_wk, cfg80211_propagate_cac_done_wk);
2895 + INIT_WORK(&rdev->mgmt_registrations_update_wk,
2896 + cfg80211_mgmt_registrations_update_wk);
2897 ++ spin_lock_init(&rdev->mgmt_registrations_lock);
2898 +
2899 + #ifdef CONFIG_CFG80211_DEFAULT_PS
2900 + rdev->wiphy.flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT;
2901 +@@ -1256,7 +1257,6 @@ void cfg80211_init_wdev(struct wireless_dev *wdev)
2902 + INIT_LIST_HEAD(&wdev->event_list);
2903 + spin_lock_init(&wdev->event_lock);
2904 + INIT_LIST_HEAD(&wdev->mgmt_registrations);
2905 +- spin_lock_init(&wdev->mgmt_registrations_lock);
2906 + INIT_LIST_HEAD(&wdev->pmsr_list);
2907 + spin_lock_init(&wdev->pmsr_lock);
2908 + INIT_WORK(&wdev->pmsr_free_wk, cfg80211_pmsr_free_wk);
2909 +diff --git a/net/wireless/core.h b/net/wireless/core.h
2910 +index 7df91f9402124..a3362a32acb32 100644
2911 +--- a/net/wireless/core.h
2912 ++++ b/net/wireless/core.h
2913 +@@ -101,6 +101,8 @@ struct cfg80211_registered_device {
2914 + struct work_struct propagate_cac_done_wk;
2915 +
2916 + struct work_struct mgmt_registrations_update_wk;
2917 ++ /* lock for all wdev lists */
2918 ++ spinlock_t mgmt_registrations_lock;
2919 +
2920 + /* must be last because of the way we do wiphy_priv(),
2921 + * and it should at least be aligned to NETDEV_ALIGN */
2922 +diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
2923 +index 0ac820780437d..6dcfc5a348742 100644
2924 +--- a/net/wireless/mlme.c
2925 ++++ b/net/wireless/mlme.c
2926 +@@ -448,9 +448,9 @@ static void cfg80211_mgmt_registrations_update(struct wireless_dev *wdev)
2927 +
2928 + ASSERT_RTNL();
2929 +
2930 +- spin_lock_bh(&wdev->mgmt_registrations_lock);
2931 ++ spin_lock_bh(&rdev->mgmt_registrations_lock);
2932 + if (!wdev->mgmt_registrations_need_update) {
2933 +- spin_unlock_bh(&wdev->mgmt_registrations_lock);
2934 ++ spin_unlock_bh(&rdev->mgmt_registrations_lock);
2935 + return;
2936 + }
2937 +
2938 +@@ -475,7 +475,7 @@ static void cfg80211_mgmt_registrations_update(struct wireless_dev *wdev)
2939 + rcu_read_unlock();
2940 +
2941 + wdev->mgmt_registrations_need_update = 0;
2942 +- spin_unlock_bh(&wdev->mgmt_registrations_lock);
2943 ++ spin_unlock_bh(&rdev->mgmt_registrations_lock);
2944 +
2945 + rdev_update_mgmt_frame_registrations(rdev, wdev, &upd);
2946 + }
2947 +@@ -499,6 +499,7 @@ int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid,
2948 + int match_len, bool multicast_rx,
2949 + struct netlink_ext_ack *extack)
2950 + {
2951 ++ struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
2952 + struct cfg80211_mgmt_registration *reg, *nreg;
2953 + int err = 0;
2954 + u16 mgmt_type;
2955 +@@ -544,7 +545,7 @@ int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid,
2956 + if (!nreg)
2957 + return -ENOMEM;
2958 +
2959 +- spin_lock_bh(&wdev->mgmt_registrations_lock);
2960 ++ spin_lock_bh(&rdev->mgmt_registrations_lock);
2961 +
2962 + list_for_each_entry(reg, &wdev->mgmt_registrations, list) {
2963 + int mlen = min(match_len, reg->match_len);
2964 +@@ -579,7 +580,7 @@ int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid,
2965 + list_add(&nreg->list, &wdev->mgmt_registrations);
2966 + }
2967 + wdev->mgmt_registrations_need_update = 1;
2968 +- spin_unlock_bh(&wdev->mgmt_registrations_lock);
2969 ++ spin_unlock_bh(&rdev->mgmt_registrations_lock);
2970 +
2971 + cfg80211_mgmt_registrations_update(wdev);
2972 +
2973 +@@ -587,7 +588,7 @@ int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid,
2974 +
2975 + out:
2976 + kfree(nreg);
2977 +- spin_unlock_bh(&wdev->mgmt_registrations_lock);
2978 ++ spin_unlock_bh(&rdev->mgmt_registrations_lock);
2979 +
2980 + return err;
2981 + }
2982 +@@ -598,7 +599,7 @@ void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlportid)
2983 + struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
2984 + struct cfg80211_mgmt_registration *reg, *tmp;
2985 +
2986 +- spin_lock_bh(&wdev->mgmt_registrations_lock);
2987 ++ spin_lock_bh(&rdev->mgmt_registrations_lock);
2988 +
2989 + list_for_each_entry_safe(reg, tmp, &wdev->mgmt_registrations, list) {
2990 + if (reg->nlportid != nlportid)
2991 +@@ -611,7 +612,7 @@ void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlportid)
2992 + schedule_work(&rdev->mgmt_registrations_update_wk);
2993 + }
2994 +
2995 +- spin_unlock_bh(&wdev->mgmt_registrations_lock);
2996 ++ spin_unlock_bh(&rdev->mgmt_registrations_lock);
2997 +
2998 + if (nlportid && rdev->crit_proto_nlportid == nlportid) {
2999 + rdev->crit_proto_nlportid = 0;
3000 +@@ -624,15 +625,16 @@ void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlportid)
3001 +
3002 + void cfg80211_mlme_purge_registrations(struct wireless_dev *wdev)
3003 + {
3004 ++ struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
3005 + struct cfg80211_mgmt_registration *reg, *tmp;
3006 +
3007 +- spin_lock_bh(&wdev->mgmt_registrations_lock);
3008 ++ spin_lock_bh(&rdev->mgmt_registrations_lock);
3009 + list_for_each_entry_safe(reg, tmp, &wdev->mgmt_registrations, list) {
3010 + list_del(&reg->list);
3011 + kfree(reg);
3012 + }
3013 + wdev->mgmt_registrations_need_update = 1;
3014 +- spin_unlock_bh(&wdev->mgmt_registrations_lock);
3015 ++ spin_unlock_bh(&rdev->mgmt_registrations_lock);
3016 +
3017 + cfg80211_mgmt_registrations_update(wdev);
3018 + }
3019 +@@ -780,7 +782,7 @@ bool cfg80211_rx_mgmt_khz(struct wireless_dev *wdev, int freq, int sig_dbm,
3020 + data = buf + ieee80211_hdrlen(mgmt->frame_control);
3021 + data_len = len - ieee80211_hdrlen(mgmt->frame_control);
3022 +
3023 +- spin_lock_bh(&wdev->mgmt_registrations_lock);
3024 ++ spin_lock_bh(&rdev->mgmt_registrations_lock);
3025 +
3026 + list_for_each_entry(reg, &wdev->mgmt_registrations, list) {
3027 + if (reg->frame_type != ftype)
3028 +@@ -804,7 +806,7 @@ bool cfg80211_rx_mgmt_khz(struct wireless_dev *wdev, int freq, int sig_dbm,
3029 + break;
3030 + }
3031 +
3032 +- spin_unlock_bh(&wdev->mgmt_registrations_lock);
3033 ++ spin_unlock_bh(&rdev->mgmt_registrations_lock);
3034 +
3035 + trace_cfg80211_return_bool(result);
3036 + return result;
3037 +diff --git a/net/wireless/scan.c b/net/wireless/scan.c
3038 +index fab1f0d504036..fd614a5a00b42 100644
3039 +--- a/net/wireless/scan.c
3040 ++++ b/net/wireless/scan.c
3041 +@@ -418,14 +418,17 @@ cfg80211_add_nontrans_list(struct cfg80211_bss *trans_bss,
3042 + }
3043 + ssid_len = ssid[1];
3044 + ssid = ssid + 2;
3045 +- rcu_read_unlock();
3046 +
3047 + /* check if nontrans_bss is in the list */
3048 + list_for_each_entry(bss, &trans_bss->nontrans_list, nontrans_list) {
3049 +- if (is_bss(bss, nontrans_bss->bssid, ssid, ssid_len))
3050 ++ if (is_bss(bss, nontrans_bss->bssid, ssid, ssid_len)) {
3051 ++ rcu_read_unlock();
3052 + return 0;
3053 ++ }
3054 + }
3055 +
3056 ++ rcu_read_unlock();
3057 ++
3058 + /* add to the list */
3059 + list_add_tail(&nontrans_bss->nontrans_list, &trans_bss->nontrans_list);
3060 + return 0;
3061 +diff --git a/net/wireless/util.c b/net/wireless/util.c
3062 +index 4fb8d1b14e76a..3f8c46bb6d9a4 100644
3063 +--- a/net/wireless/util.c
3064 ++++ b/net/wireless/util.c
3065 +@@ -1028,14 +1028,14 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev,
3066 + !(rdev->wiphy.interface_modes & (1 << ntype)))
3067 + return -EOPNOTSUPP;
3068 +
3069 +- /* if it's part of a bridge, reject changing type to station/ibss */
3070 +- if (netif_is_bridge_port(dev) &&
3071 +- (ntype == NL80211_IFTYPE_ADHOC ||
3072 +- ntype == NL80211_IFTYPE_STATION ||
3073 +- ntype == NL80211_IFTYPE_P2P_CLIENT))
3074 +- return -EBUSY;
3075 +-
3076 + if (ntype != otype) {
3077 ++ /* if it's part of a bridge, reject changing type to station/ibss */
3078 ++ if (netif_is_bridge_port(dev) &&
3079 ++ (ntype == NL80211_IFTYPE_ADHOC ||
3080 ++ ntype == NL80211_IFTYPE_STATION ||
3081 ++ ntype == NL80211_IFTYPE_P2P_CLIENT))
3082 ++ return -EBUSY;
3083 ++
3084 + dev->ieee80211_ptr->use_4addr = false;
3085 + dev->ieee80211_ptr->mesh_id_up_len = 0;
3086 + wdev_lock(dev->ieee80211_ptr);
3087 +diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
3088 +index 2bb159c105035..1d727387cb205 100644
3089 +--- a/tools/perf/builtin-script.c
3090 ++++ b/tools/perf/builtin-script.c
3091 +@@ -3820,11 +3820,15 @@ int cmd_script(int argc, const char **argv)
3092 + goto out_delete;
3093 +
3094 + uname(&uts);
3095 +- if (data.is_pipe || /* assume pipe_mode indicates native_arch */
3096 +- !strcmp(uts.machine, session->header.env.arch) ||
3097 +- (!strcmp(uts.machine, "x86_64") &&
3098 +- !strcmp(session->header.env.arch, "i386")))
3099 ++ if (data.is_pipe) { /* Assume pipe_mode indicates native_arch */
3100 + native_arch = true;
3101 ++ } else if (session->header.env.arch) {
3102 ++ if (!strcmp(uts.machine, session->header.env.arch))
3103 ++ native_arch = true;
3104 ++ else if (!strcmp(uts.machine, "x86_64") &&
3105 ++ !strcmp(session->header.env.arch, "i386"))
3106 ++ native_arch = true;
3107 ++ }
3108 +
3109 + script.session = session;
3110 + script__setup_sample_type(&script);