Magellan Linux

Annotation of /trunk/kernel-alx/patches-4.14/0178-4.14.79-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3238 - (hide annotations) (download)
Fri Nov 9 12:14:58 2018 UTC (5 years, 7 months ago) by niro
File size: 154860 byte(s)
-added up to patches-4.14.79
1 niro 3238 diff --git a/Makefile b/Makefile
2     index 89574ee68d6b..57a007bf1181 100644
3     --- a/Makefile
4     +++ b/Makefile
5     @@ -1,7 +1,7 @@
6     # SPDX-License-Identifier: GPL-2.0
7     VERSION = 4
8     PATCHLEVEL = 14
9     -SUBLEVEL = 78
10     +SUBLEVEL = 79
11     EXTRAVERSION =
12     NAME = Petit Gorille
13    
14     @@ -487,6 +487,8 @@ CLANG_GCC_TC := --gcc-toolchain=$(GCC_TOOLCHAIN)
15     endif
16     KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
17     KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
18     +KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
19     +KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
20     endif
21    
22     RETPOLINE_CFLAGS_GCC := -mindirect-branch=thunk-extern -mindirect-branch-register
23     @@ -721,8 +723,6 @@ KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
24     # See modpost pattern 2
25     KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
26     KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
27     -KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
28     -KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
29     else
30    
31     # These warnings generated too much noise in a regular build.
32     diff --git a/arch/Kconfig b/arch/Kconfig
33     index 40dc31fea90c..77b3e21c4844 100644
34     --- a/arch/Kconfig
35     +++ b/arch/Kconfig
36     @@ -965,4 +965,12 @@ config REFCOUNT_FULL
37     against various use-after-free conditions that can be used in
38     security flaw exploits.
39    
40     +config HAVE_ARCH_COMPILER_H
41     + bool
42     + help
43     + An architecture can select this if it provides an
44     + asm/compiler.h header that should be included after
45     + linux/compiler-*.h in order to override macro definitions that those
46     + headers generally provide.
47     +
48     source "kernel/gcov/Kconfig"
49     diff --git a/arch/arm/boot/dts/bcm63138.dtsi b/arch/arm/boot/dts/bcm63138.dtsi
50     index 43ee992ccdcf..6df61518776f 100644
51     --- a/arch/arm/boot/dts/bcm63138.dtsi
52     +++ b/arch/arm/boot/dts/bcm63138.dtsi
53     @@ -106,21 +106,23 @@
54     global_timer: timer@1e200 {
55     compatible = "arm,cortex-a9-global-timer";
56     reg = <0x1e200 0x20>;
57     - interrupts = <GIC_PPI 11 IRQ_TYPE_LEVEL_HIGH>;
58     + interrupts = <GIC_PPI 11 IRQ_TYPE_EDGE_RISING>;
59     clocks = <&axi_clk>;
60     };
61    
62     local_timer: local-timer@1e600 {
63     compatible = "arm,cortex-a9-twd-timer";
64     reg = <0x1e600 0x20>;
65     - interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH>;
66     + interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(2) |
67     + IRQ_TYPE_EDGE_RISING)>;
68     clocks = <&axi_clk>;
69     };
70    
71     twd_watchdog: watchdog@1e620 {
72     compatible = "arm,cortex-a9-twd-wdt";
73     reg = <0x1e620 0x20>;
74     - interrupts = <GIC_PPI 14 IRQ_TYPE_LEVEL_HIGH>;
75     + interrupts = <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(2) |
76     + IRQ_TYPE_LEVEL_HIGH)>;
77     };
78    
79     armpll: armpll {
80     @@ -158,7 +160,7 @@
81     serial0: serial@600 {
82     compatible = "brcm,bcm6345-uart";
83     reg = <0x600 0x1b>;
84     - interrupts = <GIC_SPI 32 0>;
85     + interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>;
86     clocks = <&periph_clk>;
87     clock-names = "periph";
88     status = "disabled";
89     @@ -167,7 +169,7 @@
90     serial1: serial@620 {
91     compatible = "brcm,bcm6345-uart";
92     reg = <0x620 0x1b>;
93     - interrupts = <GIC_SPI 33 0>;
94     + interrupts = <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>;
95     clocks = <&periph_clk>;
96     clock-names = "periph";
97     status = "disabled";
98     @@ -180,7 +182,7 @@
99     reg = <0x2000 0x600>, <0xf0 0x10>;
100     reg-names = "nand", "nand-int-base";
101     status = "disabled";
102     - interrupts = <GIC_SPI 38 0>;
103     + interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>;
104     interrupt-names = "nand";
105     };
106    
107     diff --git a/arch/arm/boot/dts/imx53-qsb-common.dtsi b/arch/arm/boot/dts/imx53-qsb-common.dtsi
108     index 683dcbe27cbd..8c11190c5218 100644
109     --- a/arch/arm/boot/dts/imx53-qsb-common.dtsi
110     +++ b/arch/arm/boot/dts/imx53-qsb-common.dtsi
111     @@ -130,6 +130,17 @@
112     };
113     };
114    
115     +&cpu0 {
116     + /* CPU rated to 1GHz, not 1.2GHz as per the default settings */
117     + operating-points = <
118     + /* kHz uV */
119     + 166666 850000
120     + 400000 900000
121     + 800000 1050000
122     + 1000000 1200000
123     + >;
124     +};
125     +
126     &esdhc1 {
127     pinctrl-names = "default";
128     pinctrl-0 = <&pinctrl_esdhc1>;
129     diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
130     index 16358bf8d1db..97e8b9b0b750 100644
131     --- a/arch/arm/boot/dts/r8a7790.dtsi
132     +++ b/arch/arm/boot/dts/r8a7790.dtsi
133     @@ -153,7 +153,7 @@
134    
135     trips {
136     cpu-crit {
137     - temperature = <115000>;
138     + temperature = <95000>;
139     hysteresis = <0>;
140     type = "critical";
141     };
142     diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
143     index 914f59166a99..2780e68a853b 100644
144     --- a/arch/arm/boot/dts/tegra20.dtsi
145     +++ b/arch/arm/boot/dts/tegra20.dtsi
146     @@ -706,7 +706,7 @@
147     phy_type = "ulpi";
148     clocks = <&tegra_car TEGRA20_CLK_USB2>,
149     <&tegra_car TEGRA20_CLK_PLL_U>,
150     - <&tegra_car TEGRA20_CLK_CDEV2>;
151     + <&tegra_car TEGRA20_CLK_PLL_P_OUT4>;
152     clock-names = "reg", "pll_u", "ulpi-link";
153     resets = <&tegra_car 58>, <&tegra_car 22>;
154     reset-names = "usb", "utmi-pads";
155     diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
156     index fc91205ff46c..5bf9443cfbaa 100644
157     --- a/arch/arm/mm/ioremap.c
158     +++ b/arch/arm/mm/ioremap.c
159     @@ -473,7 +473,7 @@ void pci_ioremap_set_mem_type(int mem_type)
160    
161     int pci_ioremap_io(unsigned int offset, phys_addr_t phys_addr)
162     {
163     - BUG_ON(offset + SZ_64K > IO_SPACE_LIMIT);
164     + BUG_ON(offset + SZ_64K - 1 > IO_SPACE_LIMIT);
165    
166     return ioremap_page_range(PCI_IO_VIRT_BASE + offset,
167     PCI_IO_VIRT_BASE + offset + SZ_64K,
168     diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
169     index 6cb0fa92a651..9f6ae9686dac 100644
170     --- a/arch/arm64/mm/hugetlbpage.c
171     +++ b/arch/arm64/mm/hugetlbpage.c
172     @@ -118,11 +118,14 @@ static pte_t get_clear_flush(struct mm_struct *mm,
173    
174     /*
175     * If HW_AFDBM is enabled, then the HW could turn on
176     - * the dirty bit for any page in the set, so check
177     - * them all. All hugetlb entries are already young.
178     + * the dirty or accessed bit for any page in the set,
179     + * so check them all.
180     */
181     if (pte_dirty(pte))
182     orig_pte = pte_mkdirty(orig_pte);
183     +
184     + if (pte_young(pte))
185     + orig_pte = pte_mkyoung(orig_pte);
186     }
187    
188     if (valid)
189     @@ -347,10 +350,13 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma,
190     if (!pte_same(orig_pte, pte))
191     changed = 1;
192    
193     - /* Make sure we don't lose the dirty state */
194     + /* Make sure we don't lose the dirty or young state */
195     if (pte_dirty(orig_pte))
196     pte = pte_mkdirty(pte);
197    
198     + if (pte_young(orig_pte))
199     + pte = pte_mkyoung(pte);
200     +
201     hugeprot = pte_pgprot(pte);
202     for (i = 0; i < ncontig; i++, ptep++, addr += pgsize, pfn += dpfn)
203     set_pte_at(vma->vm_mm, addr, ptep, pfn_pte(pfn, hugeprot));
204     diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
205     index c82457b0e733..23e3d3e0ee5b 100644
206     --- a/arch/mips/Kconfig
207     +++ b/arch/mips/Kconfig
208     @@ -29,6 +29,7 @@ config MIPS
209     select GENERIC_SMP_IDLE_THREAD
210     select GENERIC_TIME_VSYSCALL
211     select HANDLE_DOMAIN_IRQ
212     + select HAVE_ARCH_COMPILER_H
213     select HAVE_ARCH_JUMP_LABEL
214     select HAVE_ARCH_KGDB
215     select HAVE_ARCH_MMAP_RND_BITS if MMU
216     diff --git a/arch/mips/include/asm/compiler.h b/arch/mips/include/asm/compiler.h
217     index e081a265f422..cc2eb1b06050 100644
218     --- a/arch/mips/include/asm/compiler.h
219     +++ b/arch/mips/include/asm/compiler.h
220     @@ -8,6 +8,41 @@
221     #ifndef _ASM_COMPILER_H
222     #define _ASM_COMPILER_H
223    
224     +/*
225     + * With GCC 4.5 onwards we can use __builtin_unreachable to indicate to the
226     + * compiler that a particular code path will never be hit. This allows it to be
227     + * optimised out of the generated binary.
228     + *
229     + * Unfortunately at least GCC 4.6.3 through 7.3.0 inclusive suffer from a bug
230     + * that can lead to instructions from beyond an unreachable statement being
231     + * incorrectly reordered into earlier delay slots if the unreachable statement
232     + * is the only content of a case in a switch statement. This can lead to
233     + * seemingly random behaviour, such as invalid memory accesses from incorrectly
234     + * reordered loads or stores. See this potential GCC fix for details:
235     + *
236     + * https://gcc.gnu.org/ml/gcc-patches/2015-09/msg00360.html
237     + *
238     + * It is unclear whether GCC 8 onwards suffer from the same issue - nothing
239     + * relevant is mentioned in GCC 8 release notes and nothing obviously relevant
240     + * stands out in GCC commit logs, but these newer GCC versions generate very
241     + * different code for the testcase which doesn't exhibit the bug.
242     + *
243     + * GCC also handles stack allocation suboptimally when calling noreturn
244     + * functions or calling __builtin_unreachable():
245     + *
246     + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82365
247     + *
248     + * We work around both of these issues by placing a volatile asm statement,
249     + * which GCC is prevented from reordering past, prior to __builtin_unreachable
250     + * calls.
251     + *
252     + * The .insn statement is required to ensure that any branches to the
253     + * statement, which sadly must be kept due to the asm statement, are known to
254     + * be branches to code and satisfy linker requirements for microMIPS kernels.
255     + */
256     +#undef barrier_before_unreachable
257     +#define barrier_before_unreachable() asm volatile(".insn")
258     +
259     #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
260     #define GCC_IMM_ASM() "n"
261     #define GCC_REG_ACCUM "$0"
262     diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
263     index d5f2ee882f74..66c72b356ac0 100644
264     --- a/arch/powerpc/include/asm/topology.h
265     +++ b/arch/powerpc/include/asm/topology.h
266     @@ -81,6 +81,9 @@ static inline int numa_update_cpu_topology(bool cpus_locked)
267     {
268     return 0;
269     }
270     +
271     +static inline void update_numa_cpu_lookup_table(unsigned int cpu, int node) {}
272     +
273     #endif /* CONFIG_NUMA */
274    
275     #if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR)
276     diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c
277     index 847ddffbf38a..b5cfab711651 100644
278     --- a/arch/sparc/mm/tlb.c
279     +++ b/arch/sparc/mm/tlb.c
280     @@ -163,13 +163,10 @@ static void tlb_batch_pmd_scan(struct mm_struct *mm, unsigned long vaddr,
281     pte_unmap(pte);
282     }
283    
284     -void set_pmd_at(struct mm_struct *mm, unsigned long addr,
285     - pmd_t *pmdp, pmd_t pmd)
286     -{
287     - pmd_t orig = *pmdp;
288     -
289     - *pmdp = pmd;
290    
291     +static void __set_pmd_acct(struct mm_struct *mm, unsigned long addr,
292     + pmd_t orig, pmd_t pmd)
293     +{
294     if (mm == &init_mm)
295     return;
296    
297     @@ -219,6 +216,15 @@ void set_pmd_at(struct mm_struct *mm, unsigned long addr,
298     }
299     }
300    
301     +void set_pmd_at(struct mm_struct *mm, unsigned long addr,
302     + pmd_t *pmdp, pmd_t pmd)
303     +{
304     + pmd_t orig = *pmdp;
305     +
306     + *pmdp = pmd;
307     + __set_pmd_acct(mm, addr, orig, pmd);
308     +}
309     +
310     static inline pmd_t pmdp_establish(struct vm_area_struct *vma,
311     unsigned long address, pmd_t *pmdp, pmd_t pmd)
312     {
313     @@ -227,6 +233,7 @@ static inline pmd_t pmdp_establish(struct vm_area_struct *vma,
314     do {
315     old = *pmdp;
316     } while (cmpxchg64(&pmdp->pmd, old.pmd, pmd.pmd) != old.pmd);
317     + __set_pmd_acct(vma->vm_mm, address, old, pmd);
318    
319     return old;
320     }
321     diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c
322     index f5cbbba99283..4e1d7483b78c 100644
323     --- a/arch/x86/events/amd/uncore.c
324     +++ b/arch/x86/events/amd/uncore.c
325     @@ -35,6 +35,7 @@
326    
327     static int num_counters_llc;
328     static int num_counters_nb;
329     +static bool l3_mask;
330    
331     static HLIST_HEAD(uncore_unused_list);
332    
333     @@ -208,6 +209,13 @@ static int amd_uncore_event_init(struct perf_event *event)
334     hwc->config = event->attr.config & AMD64_RAW_EVENT_MASK_NB;
335     hwc->idx = -1;
336    
337     + /*
338     + * SliceMask and ThreadMask need to be set for certain L3 events in
339     + * Family 17h. For other events, the two fields do not affect the count.
340     + */
341     + if (l3_mask)
342     + hwc->config |= (AMD64_L3_SLICE_MASK | AMD64_L3_THREAD_MASK);
343     +
344     if (event->cpu < 0)
345     return -EINVAL;
346    
347     @@ -542,6 +550,7 @@ static int __init amd_uncore_init(void)
348     amd_llc_pmu.name = "amd_l3";
349     format_attr_event_df.show = &event_show_df;
350     format_attr_event_l3.show = &event_show_l3;
351     + l3_mask = true;
352     } else {
353     num_counters_nb = NUM_COUNTERS_NB;
354     num_counters_llc = NUM_COUNTERS_L2;
355     @@ -549,6 +558,7 @@ static int __init amd_uncore_init(void)
356     amd_llc_pmu.name = "amd_l2";
357     format_attr_event_df = format_attr_event;
358     format_attr_event_l3 = format_attr_event;
359     + l3_mask = false;
360     }
361    
362     amd_nb_pmu.attr_groups = amd_uncore_attr_groups_df;
363     diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
364     index 2dae3f585c01..a68aba8a482f 100644
365     --- a/arch/x86/events/intel/uncore_snbep.c
366     +++ b/arch/x86/events/intel/uncore_snbep.c
367     @@ -3807,16 +3807,16 @@ static const struct pci_device_id skx_uncore_pci_ids[] = {
368     .driver_data = UNCORE_PCI_DEV_FULL_DATA(21, 5, SKX_PCI_UNCORE_M2PCIE, 3),
369     },
370     { /* M3UPI0 Link 0 */
371     - PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204C),
372     - .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 0, SKX_PCI_UNCORE_M3UPI, 0),
373     + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D),
374     + .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 1, SKX_PCI_UNCORE_M3UPI, 0),
375     },
376     { /* M3UPI0 Link 1 */
377     - PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D),
378     - .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 1, SKX_PCI_UNCORE_M3UPI, 1),
379     + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204E),
380     + .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 2, SKX_PCI_UNCORE_M3UPI, 1),
381     },
382     { /* M3UPI1 Link 2 */
383     - PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204C),
384     - .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 4, SKX_PCI_UNCORE_M3UPI, 2),
385     + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D),
386     + .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 5, SKX_PCI_UNCORE_M3UPI, 2),
387     },
388     { /* end: all zeroes */ }
389     };
390     diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h
391     index 12f54082f4c8..78241b736f2a 100644
392     --- a/arch/x86/include/asm/perf_event.h
393     +++ b/arch/x86/include/asm/perf_event.h
394     @@ -46,6 +46,14 @@
395     #define INTEL_ARCH_EVENT_MASK \
396     (ARCH_PERFMON_EVENTSEL_UMASK | ARCH_PERFMON_EVENTSEL_EVENT)
397    
398     +#define AMD64_L3_SLICE_SHIFT 48
399     +#define AMD64_L3_SLICE_MASK \
400     + ((0xFULL) << AMD64_L3_SLICE_SHIFT)
401     +
402     +#define AMD64_L3_THREAD_SHIFT 56
403     +#define AMD64_L3_THREAD_MASK \
404     + ((0xFFULL) << AMD64_L3_THREAD_SHIFT)
405     +
406     #define X86_RAW_EVENT_MASK \
407     (ARCH_PERFMON_EVENTSEL_EVENT | \
408     ARCH_PERFMON_EVENTSEL_UMASK | \
409     diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
410     index f3559b84cd75..04da826381c9 100644
411     --- a/arch/x86/kernel/paravirt.c
412     +++ b/arch/x86/kernel/paravirt.c
413     @@ -90,7 +90,7 @@ unsigned paravirt_patch_call(void *insnbuf,
414    
415     if (len < 5) {
416     #ifdef CONFIG_RETPOLINE
417     - WARN_ONCE("Failing to patch indirect CALL in %ps\n", (void *)addr);
418     + WARN_ONCE(1, "Failing to patch indirect CALL in %ps\n", (void *)addr);
419     #endif
420     return len; /* call too long for patch site */
421     }
422     @@ -110,7 +110,7 @@ unsigned paravirt_patch_jmp(void *insnbuf, const void *target,
423    
424     if (len < 5) {
425     #ifdef CONFIG_RETPOLINE
426     - WARN_ONCE("Failing to patch indirect JMP in %ps\n", (void *)addr);
427     + WARN_ONCE(1, "Failing to patch indirect JMP in %ps\n", (void *)addr);
428     #endif
429     return len; /* call too long for patch site */
430     }
431     diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
432     index 5abae72266b7..6288e9d7068e 100644
433     --- a/arch/x86/kvm/paging_tmpl.h
434     +++ b/arch/x86/kvm/paging_tmpl.h
435     @@ -452,14 +452,21 @@ error:
436     * done by is_rsvd_bits_set() above.
437     *
438     * We set up the value of exit_qualification to inject:
439     - * [2:0] - Derive from [2:0] of real exit_qualification at EPT violation
440     + * [2:0] - Derive from the access bits. The exit_qualification might be
441     + * out of date if it is serving an EPT misconfiguration.
442     * [5:3] - Calculated by the page walk of the guest EPT page tables
443     * [7:8] - Derived from [7:8] of real exit_qualification
444     *
445     * The other bits are set to 0.
446     */
447     if (!(errcode & PFERR_RSVD_MASK)) {
448     - vcpu->arch.exit_qualification &= 0x187;
449     + vcpu->arch.exit_qualification &= 0x180;
450     + if (write_fault)
451     + vcpu->arch.exit_qualification |= EPT_VIOLATION_ACC_WRITE;
452     + if (user_fault)
453     + vcpu->arch.exit_qualification |= EPT_VIOLATION_ACC_READ;
454     + if (fetch_fault)
455     + vcpu->arch.exit_qualification |= EPT_VIOLATION_ACC_INSTR;
456     vcpu->arch.exit_qualification |= (pte_access & 0x7) << 3;
457     }
458     #endif
459     diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
460     index 3856828ee1dc..8d688b213504 100644
461     --- a/arch/x86/kvm/x86.c
462     +++ b/arch/x86/kvm/x86.c
463     @@ -7393,13 +7393,12 @@ static int complete_emulated_mmio(struct kvm_vcpu *vcpu)
464    
465     int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
466     {
467     - struct fpu *fpu = &current->thread.fpu;
468     int r;
469    
470     - fpu__initialize(fpu);
471     -
472     kvm_sigset_activate(vcpu);
473    
474     + kvm_load_guest_fpu(vcpu);
475     +
476     if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) {
477     if (kvm_run->immediate_exit) {
478     r = -EINTR;
479     @@ -7440,6 +7439,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
480     r = vcpu_run(vcpu);
481    
482     out:
483     + kvm_put_guest_fpu(vcpu);
484     post_kvm_run_save(vcpu);
485     kvm_sigset_deactivate(vcpu);
486    
487     diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
488     index a2070ab86c82..89d5915b1a3f 100644
489     --- a/drivers/char/tpm/tpm-interface.c
490     +++ b/drivers/char/tpm/tpm-interface.c
491     @@ -611,12 +611,13 @@ ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space,
492     rc = be32_to_cpu(header->return_code);
493     if (rc != TPM2_RC_RETRY)
494     break;
495     - delay_msec *= 2;
496     +
497     if (delay_msec > TPM2_DURATION_LONG) {
498     dev_err(&chip->dev, "TPM is in retry loop\n");
499     break;
500     }
501     tpm_msleep(delay_msec);
502     + delay_msec *= 2;
503     memcpy(buf, save, save_size);
504     }
505     return ret;
506     diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
507     index 5c7ce5aaaf6f..b4ad169836e9 100644
508     --- a/drivers/char/tpm/tpm_crb.c
509     +++ b/drivers/char/tpm/tpm_crb.c
510     @@ -520,8 +520,10 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv,
511    
512     priv->regs_t = crb_map_res(dev, priv, &io_res, buf->control_address,
513     sizeof(struct crb_regs_tail));
514     - if (IS_ERR(priv->regs_t))
515     - return PTR_ERR(priv->regs_t);
516     + if (IS_ERR(priv->regs_t)) {
517     + ret = PTR_ERR(priv->regs_t);
518     + goto out_relinquish_locality;
519     + }
520    
521     /*
522     * PTT HW bug w/a: wake up the device to access
523     @@ -529,7 +531,7 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv,
524     */
525     ret = __crb_cmd_ready(dev, priv);
526     if (ret)
527     - return ret;
528     + goto out_relinquish_locality;
529    
530     pa_high = ioread32(&priv->regs_t->ctrl_cmd_pa_high);
531     pa_low = ioread32(&priv->regs_t->ctrl_cmd_pa_low);
532     @@ -574,6 +576,8 @@ out:
533    
534     __crb_go_idle(dev, priv);
535    
536     +out_relinquish_locality:
537     +
538     __crb_relinquish_locality(dev, priv, 0);
539    
540     return ret;
541     diff --git a/drivers/gpu/drm/i915/gvt/cmd_parser.c b/drivers/gpu/drm/i915/gvt/cmd_parser.c
542     index d4726a3358a4..d6993c2707d1 100644
543     --- a/drivers/gpu/drm/i915/gvt/cmd_parser.c
544     +++ b/drivers/gpu/drm/i915/gvt/cmd_parser.c
545     @@ -2802,6 +2802,7 @@ static int init_cmd_table(struct intel_gvt *gvt)
546     if (info) {
547     gvt_err("%s %s duplicated\n", e->info->name,
548     info->name);
549     + kfree(e);
550     return -EEXIST;
551     }
552    
553     diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
554     index ab70194a73db..c3a4f5d92391 100644
555     --- a/drivers/infiniband/hw/mlx5/main.c
556     +++ b/drivers/infiniband/hw/mlx5/main.c
557     @@ -3911,7 +3911,7 @@ mlx5_ib_get_vector_affinity(struct ib_device *ibdev, int comp_vector)
558     {
559     struct mlx5_ib_dev *dev = to_mdev(ibdev);
560    
561     - return mlx5_get_vector_affinity(dev->mdev, comp_vector);
562     + return mlx5_get_vector_affinity_hint(dev->mdev, comp_vector);
563     }
564    
565     static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
566     diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
567     index ef9ee6c328a1..dfc190055167 100644
568     --- a/drivers/infiniband/hw/mlx5/qp.c
569     +++ b/drivers/infiniband/hw/mlx5/qp.c
570     @@ -1527,6 +1527,7 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
571     u32 uidx = MLX5_IB_DEFAULT_UIDX;
572     struct mlx5_ib_create_qp ucmd;
573     struct mlx5_ib_qp_base *base;
574     + int mlx5_st;
575     void *qpc;
576     u32 *in;
577     int err;
578     @@ -1535,6 +1536,10 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
579     spin_lock_init(&qp->sq.lock);
580     spin_lock_init(&qp->rq.lock);
581    
582     + mlx5_st = to_mlx5_st(init_attr->qp_type);
583     + if (mlx5_st < 0)
584     + return -EINVAL;
585     +
586     if (init_attr->rwq_ind_tbl) {
587     if (!udata)
588     return -ENOSYS;
589     @@ -1688,7 +1693,7 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
590    
591     qpc = MLX5_ADDR_OF(create_qp_in, in, qpc);
592    
593     - MLX5_SET(qpc, qpc, st, to_mlx5_st(init_attr->qp_type));
594     + MLX5_SET(qpc, qpc, st, mlx5_st);
595     MLX5_SET(qpc, qpc, pm_state, MLX5_QP_PM_MIGRATED);
596    
597     if (init_attr->qp_type != MLX5_IB_QPT_REG_UMR)
598     diff --git a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
599     index e4113ef09315..3c3453d213dc 100644
600     --- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
601     +++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
602     @@ -642,7 +642,7 @@ int usnic_ib_dereg_mr(struct ib_mr *ibmr)
603    
604     usnic_dbg("va 0x%lx length 0x%zx\n", mr->umem->va, mr->umem->length);
605    
606     - usnic_uiom_reg_release(mr->umem, ibmr->pd->uobject->context->closing);
607     + usnic_uiom_reg_release(mr->umem, ibmr->uobject->context);
608     kfree(mr);
609     return 0;
610     }
611     diff --git a/drivers/infiniband/hw/usnic/usnic_uiom.c b/drivers/infiniband/hw/usnic/usnic_uiom.c
612     index 4381c0a9a873..9dd39daa602b 100644
613     --- a/drivers/infiniband/hw/usnic/usnic_uiom.c
614     +++ b/drivers/infiniband/hw/usnic/usnic_uiom.c
615     @@ -41,6 +41,7 @@
616     #include <linux/workqueue.h>
617     #include <linux/list.h>
618     #include <linux/pci.h>
619     +#include <rdma/ib_verbs.h>
620    
621     #include "usnic_log.h"
622     #include "usnic_uiom.h"
623     @@ -88,7 +89,7 @@ static void usnic_uiom_put_pages(struct list_head *chunk_list, int dirty)
624     for_each_sg(chunk->page_list, sg, chunk->nents, i) {
625     page = sg_page(sg);
626     pa = sg_phys(sg);
627     - if (dirty)
628     + if (!PageDirty(page) && dirty)
629     set_page_dirty_lock(page);
630     put_page(page);
631     usnic_dbg("pa: %pa\n", &pa);
632     @@ -114,6 +115,16 @@ static int usnic_uiom_get_pages(unsigned long addr, size_t size, int writable,
633     dma_addr_t pa;
634     unsigned int gup_flags;
635    
636     + /*
637     + * If the combination of the addr and size requested for this memory
638     + * region causes an integer overflow, return error.
639     + */
640     + if (((addr + size) < addr) || PAGE_ALIGN(addr + size) < (addr + size))
641     + return -EINVAL;
642     +
643     + if (!size)
644     + return -EINVAL;
645     +
646     if (!can_do_mlock())
647     return -EPERM;
648    
649     @@ -127,7 +138,7 @@ static int usnic_uiom_get_pages(unsigned long addr, size_t size, int writable,
650    
651     down_write(&current->mm->mmap_sem);
652    
653     - locked = npages + current->mm->locked_vm;
654     + locked = npages + current->mm->pinned_vm;
655     lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
656    
657     if ((locked > lock_limit) && !capable(CAP_IPC_LOCK)) {
658     @@ -143,7 +154,7 @@ static int usnic_uiom_get_pages(unsigned long addr, size_t size, int writable,
659     ret = 0;
660    
661     while (npages) {
662     - ret = get_user_pages(cur_base,
663     + ret = get_user_pages_longterm(cur_base,
664     min_t(unsigned long, npages,
665     PAGE_SIZE / sizeof(struct page *)),
666     gup_flags, page_list, NULL);
667     @@ -186,7 +197,7 @@ out:
668     if (ret < 0)
669     usnic_uiom_put_pages(chunk_list, 0);
670     else
671     - current->mm->locked_vm = locked;
672     + current->mm->pinned_vm = locked;
673    
674     up_write(&current->mm->mmap_sem);
675     free_page((unsigned long) page_list);
676     @@ -420,18 +431,22 @@ out_free_uiomr:
677     return ERR_PTR(err);
678     }
679    
680     -void usnic_uiom_reg_release(struct usnic_uiom_reg *uiomr, int closing)
681     +void usnic_uiom_reg_release(struct usnic_uiom_reg *uiomr,
682     + struct ib_ucontext *ucontext)
683     {
684     + struct task_struct *task;
685     struct mm_struct *mm;
686     unsigned long diff;
687    
688     __usnic_uiom_reg_release(uiomr->pd, uiomr, 1);
689    
690     - mm = get_task_mm(current);
691     - if (!mm) {
692     - kfree(uiomr);
693     - return;
694     - }
695     + task = get_pid_task(ucontext->tgid, PIDTYPE_PID);
696     + if (!task)
697     + goto out;
698     + mm = get_task_mm(task);
699     + put_task_struct(task);
700     + if (!mm)
701     + goto out;
702    
703     diff = PAGE_ALIGN(uiomr->length + uiomr->offset) >> PAGE_SHIFT;
704    
705     @@ -443,7 +458,7 @@ void usnic_uiom_reg_release(struct usnic_uiom_reg *uiomr, int closing)
706     * up here and not be able to take the mmap_sem. In that case
707     * we defer the vm_locked accounting to the system workqueue.
708     */
709     - if (closing) {
710     + if (ucontext->closing) {
711     if (!down_write_trylock(&mm->mmap_sem)) {
712     INIT_WORK(&uiomr->work, usnic_uiom_reg_account);
713     uiomr->mm = mm;
714     @@ -455,9 +470,10 @@ void usnic_uiom_reg_release(struct usnic_uiom_reg *uiomr, int closing)
715     } else
716     down_write(&mm->mmap_sem);
717    
718     - current->mm->locked_vm -= diff;
719     + mm->pinned_vm -= diff;
720     up_write(&mm->mmap_sem);
721     mmput(mm);
722     +out:
723     kfree(uiomr);
724     }
725    
726     diff --git a/drivers/infiniband/hw/usnic/usnic_uiom.h b/drivers/infiniband/hw/usnic/usnic_uiom.h
727     index 431efe4143f4..8c096acff123 100644
728     --- a/drivers/infiniband/hw/usnic/usnic_uiom.h
729     +++ b/drivers/infiniband/hw/usnic/usnic_uiom.h
730     @@ -39,6 +39,8 @@
731    
732     #include "usnic_uiom_interval_tree.h"
733    
734     +struct ib_ucontext;
735     +
736     #define USNIC_UIOM_READ (1)
737     #define USNIC_UIOM_WRITE (2)
738    
739     @@ -89,7 +91,8 @@ void usnic_uiom_free_dev_list(struct device **devs);
740     struct usnic_uiom_reg *usnic_uiom_reg_get(struct usnic_uiom_pd *pd,
741     unsigned long addr, size_t size,
742     int access, int dmasync);
743     -void usnic_uiom_reg_release(struct usnic_uiom_reg *uiomr, int closing);
744     +void usnic_uiom_reg_release(struct usnic_uiom_reg *uiomr,
745     + struct ib_ucontext *ucontext);
746     int usnic_uiom_init(char *drv_name);
747     void usnic_uiom_fini(void);
748     #endif /* USNIC_UIOM_H_ */
749     diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c
750     index 3b4916680018..b4a8acc7bb7d 100644
751     --- a/drivers/infiniband/sw/rxe/rxe_pool.c
752     +++ b/drivers/infiniband/sw/rxe/rxe_pool.c
753     @@ -394,23 +394,25 @@ void *rxe_alloc(struct rxe_pool *pool)
754    
755     kref_get(&pool->rxe->ref_cnt);
756    
757     - if (atomic_inc_return(&pool->num_elem) > pool->max_elem) {
758     - atomic_dec(&pool->num_elem);
759     - rxe_dev_put(pool->rxe);
760     - rxe_pool_put(pool);
761     - return NULL;
762     - }
763     + if (atomic_inc_return(&pool->num_elem) > pool->max_elem)
764     + goto out_put_pool;
765    
766     elem = kmem_cache_zalloc(pool_cache(pool),
767     (pool->flags & RXE_POOL_ATOMIC) ?
768     GFP_ATOMIC : GFP_KERNEL);
769     if (!elem)
770     - return NULL;
771     + goto out_put_pool;
772    
773     elem->pool = pool;
774     kref_init(&elem->ref_cnt);
775    
776     return elem;
777     +
778     +out_put_pool:
779     + atomic_dec(&pool->num_elem);
780     + rxe_dev_put(pool->rxe);
781     + rxe_pool_put(pool);
782     + return NULL;
783     }
784    
785     void rxe_elem_release(struct kref *kref)
786     diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
787     index c97384c914a4..d77e8e2ae05f 100644
788     --- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
789     +++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
790     @@ -1203,13 +1203,10 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv,
791     ipoib_ib_dev_down(dev);
792    
793     if (level == IPOIB_FLUSH_HEAVY) {
794     - rtnl_lock();
795     if (test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags))
796     ipoib_ib_dev_stop(dev);
797    
798     - result = ipoib_ib_dev_open(dev);
799     - rtnl_unlock();
800     - if (result)
801     + if (ipoib_ib_dev_open(dev))
802     return;
803    
804     if (netif_queue_stopped(dev))
805     @@ -1249,7 +1246,9 @@ void ipoib_ib_dev_flush_heavy(struct work_struct *work)
806     struct ipoib_dev_priv *priv =
807     container_of(work, struct ipoib_dev_priv, flush_heavy);
808    
809     + rtnl_lock();
810     __ipoib_ib_dev_flush(priv, IPOIB_FLUSH_HEAVY, 0);
811     + rtnl_unlock();
812     }
813    
814     void ipoib_ib_dev_cleanup(struct net_device *dev)
815     diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
816     index 898286ed47a1..b10e4c5641ea 100644
817     --- a/drivers/md/dm-integrity.c
818     +++ b/drivers/md/dm-integrity.c
819     @@ -2547,6 +2547,9 @@ static int get_mac(struct crypto_shash **hash, struct alg_spec *a, char **error,
820     *error = error_key;
821     return r;
822     }
823     + } else if (crypto_shash_get_flags(*hash) & CRYPTO_TFM_NEED_KEY) {
824     + *error = error_key;
825     + return -ENOKEY;
826     }
827     }
828    
829     diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
830     index 6d22b22cb35b..064d88299adc 100644
831     --- a/drivers/media/usb/uvc/uvc_driver.c
832     +++ b/drivers/media/usb/uvc/uvc_driver.c
833     @@ -1865,13 +1865,6 @@ static void uvc_unregister_video(struct uvc_device *dev)
834     {
835     struct uvc_streaming *stream;
836    
837     - /* Unregistering all video devices might result in uvc_delete() being
838     - * called from inside the loop if there's no open file handle. To avoid
839     - * that, increment the refcount before iterating over the streams and
840     - * decrement it when done.
841     - */
842     - kref_get(&dev->ref);
843     -
844     list_for_each_entry(stream, &dev->streams, list) {
845     if (!video_is_registered(&stream->vdev))
846     continue;
847     @@ -1880,8 +1873,6 @@ static void uvc_unregister_video(struct uvc_device *dev)
848    
849     uvc_debugfs_cleanup_stream(stream);
850     }
851     -
852     - kref_put(&dev->ref, uvc_delete);
853     }
854    
855     static int uvc_register_video(struct uvc_device *dev,
856     @@ -2129,6 +2120,7 @@ static int uvc_probe(struct usb_interface *intf,
857    
858     error:
859     uvc_unregister_video(dev);
860     + kref_put(&dev->ref, uvc_delete);
861     return -ENODEV;
862     }
863    
864     @@ -2146,6 +2138,7 @@ static void uvc_disconnect(struct usb_interface *intf)
865     return;
866    
867     uvc_unregister_video(dev);
868     + kref_put(&dev->ref, uvc_delete);
869     }
870    
871     static int uvc_suspend(struct usb_interface *intf, pm_message_t message)
872     diff --git a/drivers/mmc/host/dw_mmc-rockchip.c b/drivers/mmc/host/dw_mmc-rockchip.c
873     index 339295212935..40d7de2eea12 100644
874     --- a/drivers/mmc/host/dw_mmc-rockchip.c
875     +++ b/drivers/mmc/host/dw_mmc-rockchip.c
876     @@ -282,11 +282,11 @@ static int dw_mci_rk3288_parse_dt(struct dw_mci *host)
877    
878     priv->drv_clk = devm_clk_get(host->dev, "ciu-drive");
879     if (IS_ERR(priv->drv_clk))
880     - dev_dbg(host->dev, "ciu_drv not available\n");
881     + dev_dbg(host->dev, "ciu-drive not available\n");
882    
883     priv->sample_clk = devm_clk_get(host->dev, "ciu-sample");
884     if (IS_ERR(priv->sample_clk))
885     - dev_dbg(host->dev, "ciu_sample not available\n");
886     + dev_dbg(host->dev, "ciu-sample not available\n");
887    
888     host->priv = priv;
889    
890     diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
891     index 19c000722cbc..34ecc12ee3d9 100644
892     --- a/drivers/mtd/spi-nor/spi-nor.c
893     +++ b/drivers/mtd/spi-nor/spi-nor.c
894     @@ -1005,6 +1005,12 @@ static const struct flash_info spi_nor_ids[] = {
895    
896     /* ISSI */
897     { "is25cd512", INFO(0x7f9d20, 0, 32 * 1024, 2, SECT_4K) },
898     + { "is25wp032", INFO(0x9d7016, 0, 64 * 1024, 64,
899     + SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
900     + { "is25wp064", INFO(0x9d7017, 0, 64 * 1024, 128,
901     + SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
902     + { "is25wp128", INFO(0x9d7018, 0, 64 * 1024, 256,
903     + SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
904    
905     /* Macronix */
906     { "mx25l512e", INFO(0xc22010, 0, 64 * 1024, 1, SECT_4K) },
907     diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
908     index a1b33aa6054a..77babf1417a7 100644
909     --- a/drivers/net/bonding/bond_netlink.c
910     +++ b/drivers/net/bonding/bond_netlink.c
911     @@ -638,8 +638,7 @@ static int bond_fill_info(struct sk_buff *skb,
912     goto nla_put_failure;
913    
914     if (nla_put(skb, IFLA_BOND_AD_ACTOR_SYSTEM,
915     - sizeof(bond->params.ad_actor_system),
916     - &bond->params.ad_actor_system))
917     + ETH_ALEN, &bond->params.ad_actor_system))
918     goto nla_put_failure;
919     }
920     if (!bond_3ad_get_active_agg_info(bond, &info)) {
921     diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
922     index 60b3ee29d82c..3c7813f04962 100644
923     --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
924     +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
925     @@ -1571,8 +1571,6 @@ static int ena_up_complete(struct ena_adapter *adapter)
926     if (rc)
927     return rc;
928    
929     - ena_init_napi(adapter);
930     -
931     ena_change_mtu(adapter->netdev, adapter->netdev->mtu);
932    
933     ena_refill_all_rx_bufs(adapter);
934     @@ -1726,6 +1724,13 @@ static int ena_up(struct ena_adapter *adapter)
935    
936     ena_setup_io_intr(adapter);
937    
938     + /* napi poll functions should be initialized before running
939     + * request_irq(), to handle a rare condition where there is a pending
940     + * interrupt, causing the ISR to fire immediately while the poll
941     + * function wasn't set yet, causing a null dereference
942     + */
943     + ena_init_napi(adapter);
944     +
945     rc = ena_request_io_irq(adapter);
946     if (rc)
947     goto err_req_irq;
948     @@ -3059,15 +3064,8 @@ err_rss_init:
949    
950     static void ena_release_bars(struct ena_com_dev *ena_dev, struct pci_dev *pdev)
951     {
952     - int release_bars;
953     -
954     - if (ena_dev->mem_bar)
955     - devm_iounmap(&pdev->dev, ena_dev->mem_bar);
956     -
957     - if (ena_dev->reg_bar)
958     - devm_iounmap(&pdev->dev, ena_dev->reg_bar);
959     + int release_bars = pci_select_bars(pdev, IORESOURCE_MEM) & ENA_BAR_MASK;
960    
961     - release_bars = pci_select_bars(pdev, IORESOURCE_MEM) & ENA_BAR_MASK;
962     pci_release_selected_regions(pdev, release_bars);
963     }
964    
965     diff --git a/drivers/net/ethernet/amd/declance.c b/drivers/net/ethernet/amd/declance.c
966     index 82cc81385033..c7cde58feaf7 100644
967     --- a/drivers/net/ethernet/amd/declance.c
968     +++ b/drivers/net/ethernet/amd/declance.c
969     @@ -1029,6 +1029,7 @@ static int dec_lance_probe(struct device *bdev, const int type)
970     int i, ret;
971     unsigned long esar_base;
972     unsigned char *esar;
973     + const char *desc;
974    
975     if (dec_lance_debug && version_printed++ == 0)
976     printk(version);
977     @@ -1214,19 +1215,20 @@ static int dec_lance_probe(struct device *bdev, const int type)
978     */
979     switch (type) {
980     case ASIC_LANCE:
981     - printk("%s: IOASIC onboard LANCE", name);
982     + desc = "IOASIC onboard LANCE";
983     break;
984     case PMAD_LANCE:
985     - printk("%s: PMAD-AA", name);
986     + desc = "PMAD-AA";
987     break;
988     case PMAX_LANCE:
989     - printk("%s: PMAX onboard LANCE", name);
990     + desc = "PMAX onboard LANCE";
991     break;
992     }
993     for (i = 0; i < 6; i++)
994     dev->dev_addr[i] = esar[i * 4];
995    
996     - printk(", addr = %pM, irq = %d\n", dev->dev_addr, dev->irq);
997     + printk("%s: %s, addr = %pM, irq = %d\n",
998     + name, desc, dev->dev_addr, dev->irq);
999    
1000     dev->netdev_ops = &lance_netdev_ops;
1001     dev->watchdog_timeo = 5*HZ;
1002     diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
1003     index 6ad0ca7ed3e9..abbd2894f870 100644
1004     --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
1005     +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
1006     @@ -339,9 +339,12 @@ int bcmgenet_mii_probe(struct net_device *dev)
1007     phydev->advertising = phydev->supported;
1008    
1009     /* The internal PHY has its link interrupts routed to the
1010     - * Ethernet MAC ISRs
1011     - */
1012     - if (priv->internal_phy)
1013     + * Ethernet MAC ISRs. On GENETv5 there is a hardware issue
1014     + * that prevents the signaling of link UP interrupts when
1015     + * the link operates at 10Mbps, so fallback to polling for
1016     + * those versions of GENET.
1017     + */
1018     + if (priv->internal_phy && !GENET_IS_V5(priv))
1019     priv->phydev->irq = PHY_IGNORE_INTERRUPT;
1020    
1021     return 0;
1022     diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
1023     index b4f92de1efbd..d6f8d6c8b0f1 100644
1024     --- a/drivers/net/ethernet/cadence/macb_main.c
1025     +++ b/drivers/net/ethernet/cadence/macb_main.c
1026     @@ -2000,6 +2000,7 @@ static void macb_configure_dma(struct macb *bp)
1027     else
1028     dmacfg &= ~GEM_BIT(TXCOEN);
1029    
1030     + dmacfg &= ~GEM_BIT(ADDR64);
1031     #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
1032     if (bp->hw_dma_cap & HW_DMA_CAP_64B)
1033     dmacfg |= GEM_BIT(ADDR64);
1034     diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
1035     index bf291e90cdb0..79053d2ce7a3 100644
1036     --- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
1037     +++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
1038     @@ -2159,6 +2159,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr)
1039     return -EPERM;
1040     if (copy_from_user(&t, useraddr, sizeof(t)))
1041     return -EFAULT;
1042     + if (t.cmd != CHELSIO_SET_QSET_PARAMS)
1043     + return -EINVAL;
1044     if (t.qset_idx >= SGE_QSETS)
1045     return -EINVAL;
1046     if (!in_range(t.intr_lat, 0, M_NEWTIMER) ||
1047     @@ -2258,6 +2260,9 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr)
1048     if (copy_from_user(&t, useraddr, sizeof(t)))
1049     return -EFAULT;
1050    
1051     + if (t.cmd != CHELSIO_GET_QSET_PARAMS)
1052     + return -EINVAL;
1053     +
1054     /* Display qsets for all ports when offload enabled */
1055     if (test_bit(OFFLOAD_DEVMAP_BIT, &adapter->open_device_map)) {
1056     q1 = 0;
1057     @@ -2303,6 +2308,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr)
1058     return -EBUSY;
1059     if (copy_from_user(&edata, useraddr, sizeof(edata)))
1060     return -EFAULT;
1061     + if (edata.cmd != CHELSIO_SET_QSET_NUM)
1062     + return -EINVAL;
1063     if (edata.val < 1 ||
1064     (edata.val > 1 && !(adapter->flags & USING_MSIX)))
1065     return -EINVAL;
1066     @@ -2343,6 +2350,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr)
1067     return -EPERM;
1068     if (copy_from_user(&t, useraddr, sizeof(t)))
1069     return -EFAULT;
1070     + if (t.cmd != CHELSIO_LOAD_FW)
1071     + return -EINVAL;
1072     /* Check t.len sanity ? */
1073     fw_data = memdup_user(useraddr + sizeof(t), t.len);
1074     if (IS_ERR(fw_data))
1075     @@ -2366,6 +2375,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr)
1076     return -EBUSY;
1077     if (copy_from_user(&m, useraddr, sizeof(m)))
1078     return -EFAULT;
1079     + if (m.cmd != CHELSIO_SETMTUTAB)
1080     + return -EINVAL;
1081     if (m.nmtus != NMTUS)
1082     return -EINVAL;
1083     if (m.mtus[0] < 81) /* accommodate SACK */
1084     @@ -2407,6 +2418,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr)
1085     return -EBUSY;
1086     if (copy_from_user(&m, useraddr, sizeof(m)))
1087     return -EFAULT;
1088     + if (m.cmd != CHELSIO_SET_PM)
1089     + return -EINVAL;
1090     if (!is_power_of_2(m.rx_pg_sz) ||
1091     !is_power_of_2(m.tx_pg_sz))
1092     return -EINVAL; /* not power of 2 */
1093     @@ -2440,6 +2453,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr)
1094     return -EIO; /* need the memory controllers */
1095     if (copy_from_user(&t, useraddr, sizeof(t)))
1096     return -EFAULT;
1097     + if (t.cmd != CHELSIO_GET_MEM)
1098     + return -EINVAL;
1099     if ((t.addr & 7) || (t.len & 7))
1100     return -EINVAL;
1101     if (t.mem_id == MEM_CM)
1102     @@ -2492,6 +2507,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr)
1103     return -EAGAIN;
1104     if (copy_from_user(&t, useraddr, sizeof(t)))
1105     return -EFAULT;
1106     + if (t.cmd != CHELSIO_SET_TRACE_FILTER)
1107     + return -EINVAL;
1108    
1109     tp = (const struct trace_params *)&t.sip;
1110     if (t.config_tx)
1111     diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
1112     index 2bfaf3e118b1..03f4fee1bbc9 100644
1113     --- a/drivers/net/ethernet/cisco/enic/enic_main.c
1114     +++ b/drivers/net/ethernet/cisco/enic/enic_main.c
1115     @@ -1879,7 +1879,7 @@ static int enic_open(struct net_device *netdev)
1116     {
1117     struct enic *enic = netdev_priv(netdev);
1118     unsigned int i;
1119     - int err;
1120     + int err, ret;
1121    
1122     err = enic_request_intr(enic);
1123     if (err) {
1124     @@ -1936,10 +1936,9 @@ static int enic_open(struct net_device *netdev)
1125    
1126     err_out_free_rq:
1127     for (i = 0; i < enic->rq_count; i++) {
1128     - err = vnic_rq_disable(&enic->rq[i]);
1129     - if (err)
1130     - return err;
1131     - vnic_rq_clean(&enic->rq[i], enic_free_rq_buf);
1132     + ret = vnic_rq_disable(&enic->rq[i]);
1133     + if (!ret)
1134     + vnic_rq_clean(&enic->rq[i], enic_free_rq_buf);
1135     }
1136     enic_dev_notify_unset(enic);
1137     err_out_free_intr:
1138     diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
1139     index 7e2b70c2bba3..39f399741647 100644
1140     --- a/drivers/net/ethernet/emulex/benet/be_main.c
1141     +++ b/drivers/net/ethernet/emulex/benet/be_main.c
1142     @@ -3900,8 +3900,6 @@ static int be_enable_vxlan_offloads(struct be_adapter *adapter)
1143     netdev->hw_enc_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
1144     NETIF_F_TSO | NETIF_F_TSO6 |
1145     NETIF_F_GSO_UDP_TUNNEL;
1146     - netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL;
1147     - netdev->features |= NETIF_F_GSO_UDP_TUNNEL;
1148    
1149     dev_info(dev, "Enabled VxLAN offloads for UDP port %d\n",
1150     be16_to_cpu(port));
1151     @@ -3923,8 +3921,6 @@ static void be_disable_vxlan_offloads(struct be_adapter *adapter)
1152     adapter->vxlan_port = 0;
1153    
1154     netdev->hw_enc_features = 0;
1155     - netdev->hw_features &= ~(NETIF_F_GSO_UDP_TUNNEL);
1156     - netdev->features &= ~(NETIF_F_GSO_UDP_TUNNEL);
1157     }
1158    
1159     static void be_calculate_vf_res(struct be_adapter *adapter, u16 num_vfs,
1160     @@ -5215,6 +5211,7 @@ static void be_netdev_init(struct net_device *netdev)
1161     struct be_adapter *adapter = netdev_priv(netdev);
1162    
1163     netdev->hw_features |= NETIF_F_SG | NETIF_F_TSO | NETIF_F_TSO6 |
1164     + NETIF_F_GSO_UDP_TUNNEL |
1165     NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |
1166     NETIF_F_HW_VLAN_CTAG_TX;
1167     if ((be_if_cap_flags(adapter) & BE_IF_FLAGS_RSS))
1168     diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
1169     index 44720f83af27..4d4f16ad88c3 100644
1170     --- a/drivers/net/ethernet/freescale/fec.h
1171     +++ b/drivers/net/ethernet/freescale/fec.h
1172     @@ -451,6 +451,10 @@ struct bufdesc_ex {
1173     * initialisation.
1174     */
1175     #define FEC_QUIRK_MIB_CLEAR (1 << 15)
1176     +/* Only i.MX25/i.MX27/i.MX28 controller supports FRBR,FRSR registers,
1177     + * those FIFO receive registers are resolved in other platforms.
1178     + */
1179     +#define FEC_QUIRK_HAS_FRREG (1 << 16)
1180    
1181     struct bufdesc_prop {
1182     int qid;
1183     diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
1184     index eb2ea231c7ca..ce55c8f7f33a 100644
1185     --- a/drivers/net/ethernet/freescale/fec_main.c
1186     +++ b/drivers/net/ethernet/freescale/fec_main.c
1187     @@ -89,14 +89,16 @@ static struct platform_device_id fec_devtype[] = {
1188     .driver_data = 0,
1189     }, {
1190     .name = "imx25-fec",
1191     - .driver_data = FEC_QUIRK_USE_GASKET | FEC_QUIRK_MIB_CLEAR,
1192     + .driver_data = FEC_QUIRK_USE_GASKET | FEC_QUIRK_MIB_CLEAR |
1193     + FEC_QUIRK_HAS_FRREG,
1194     }, {
1195     .name = "imx27-fec",
1196     - .driver_data = FEC_QUIRK_MIB_CLEAR,
1197     + .driver_data = FEC_QUIRK_MIB_CLEAR | FEC_QUIRK_HAS_FRREG,
1198     }, {
1199     .name = "imx28-fec",
1200     .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_SWAP_FRAME |
1201     - FEC_QUIRK_SINGLE_MDIO | FEC_QUIRK_HAS_RACC,
1202     + FEC_QUIRK_SINGLE_MDIO | FEC_QUIRK_HAS_RACC |
1203     + FEC_QUIRK_HAS_FRREG,
1204     }, {
1205     .name = "imx6q-fec",
1206     .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT |
1207     @@ -1155,7 +1157,7 @@ static void fec_enet_timeout_work(struct work_struct *work)
1208     napi_disable(&fep->napi);
1209     netif_tx_lock_bh(ndev);
1210     fec_restart(ndev);
1211     - netif_wake_queue(ndev);
1212     + netif_tx_wake_all_queues(ndev);
1213     netif_tx_unlock_bh(ndev);
1214     napi_enable(&fep->napi);
1215     }
1216     @@ -1270,7 +1272,7 @@ skb_done:
1217    
1218     /* Since we have freed up a buffer, the ring is no longer full
1219     */
1220     - if (netif_queue_stopped(ndev)) {
1221     + if (netif_tx_queue_stopped(nq)) {
1222     entries_free = fec_enet_get_free_txdesc_num(txq);
1223     if (entries_free >= txq->tx_wake_threshold)
1224     netif_tx_wake_queue(nq);
1225     @@ -1747,7 +1749,7 @@ static void fec_enet_adjust_link(struct net_device *ndev)
1226     napi_disable(&fep->napi);
1227     netif_tx_lock_bh(ndev);
1228     fec_restart(ndev);
1229     - netif_wake_queue(ndev);
1230     + netif_tx_wake_all_queues(ndev);
1231     netif_tx_unlock_bh(ndev);
1232     napi_enable(&fep->napi);
1233     }
1234     @@ -2166,7 +2168,13 @@ static void fec_enet_get_regs(struct net_device *ndev,
1235     memset(buf, 0, regs->len);
1236    
1237     for (i = 0; i < ARRAY_SIZE(fec_enet_register_offset); i++) {
1238     - off = fec_enet_register_offset[i] / 4;
1239     + off = fec_enet_register_offset[i];
1240     +
1241     + if ((off == FEC_R_BOUND || off == FEC_R_FSTART) &&
1242     + !(fep->quirks & FEC_QUIRK_HAS_FRREG))
1243     + continue;
1244     +
1245     + off >>= 2;
1246     buf[off] = readl(&theregs[off]);
1247     }
1248     }
1249     @@ -2249,7 +2257,7 @@ static int fec_enet_set_pauseparam(struct net_device *ndev,
1250     napi_disable(&fep->napi);
1251     netif_tx_lock_bh(ndev);
1252     fec_restart(ndev);
1253     - netif_wake_queue(ndev);
1254     + netif_tx_wake_all_queues(ndev);
1255     netif_tx_unlock_bh(ndev);
1256     napi_enable(&fep->napi);
1257     }
1258     diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
1259     index 9d64d0759ee9..a5dd99aaf321 100644
1260     --- a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
1261     +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
1262     @@ -257,7 +257,8 @@ int mlx5e_dcbnl_ieee_setets_core(struct mlx5e_priv *priv, struct ieee_ets *ets)
1263     }
1264    
1265     static int mlx5e_dbcnl_validate_ets(struct net_device *netdev,
1266     - struct ieee_ets *ets)
1267     + struct ieee_ets *ets,
1268     + bool zero_sum_allowed)
1269     {
1270     bool have_ets_tc = false;
1271     int bw_sum = 0;
1272     @@ -282,8 +283,9 @@ static int mlx5e_dbcnl_validate_ets(struct net_device *netdev,
1273     }
1274    
1275     if (have_ets_tc && bw_sum != 100) {
1276     - netdev_err(netdev,
1277     - "Failed to validate ETS: BW sum is illegal\n");
1278     + if (bw_sum || (!bw_sum && !zero_sum_allowed))
1279     + netdev_err(netdev,
1280     + "Failed to validate ETS: BW sum is illegal\n");
1281     return -EINVAL;
1282     }
1283     return 0;
1284     @@ -298,7 +300,7 @@ static int mlx5e_dcbnl_ieee_setets(struct net_device *netdev,
1285     if (!MLX5_CAP_GEN(priv->mdev, ets))
1286     return -EOPNOTSUPP;
1287    
1288     - err = mlx5e_dbcnl_validate_ets(netdev, ets);
1289     + err = mlx5e_dbcnl_validate_ets(netdev, ets, false);
1290     if (err)
1291     return err;
1292    
1293     @@ -477,12 +479,9 @@ static u8 mlx5e_dcbnl_setall(struct net_device *netdev)
1294     ets.prio_tc[i] = cee_cfg->prio_to_pg_map[i];
1295     }
1296    
1297     - err = mlx5e_dbcnl_validate_ets(netdev, &ets);
1298     - if (err) {
1299     - netdev_err(netdev,
1300     - "%s, Failed to validate ETS: %d\n", __func__, err);
1301     + err = mlx5e_dbcnl_validate_ets(netdev, &ets, true);
1302     + if (err)
1303     goto out;
1304     - }
1305    
1306     err = mlx5e_dcbnl_ieee_setets_core(priv, &ets);
1307     if (err) {
1308     diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
1309     index 8285e6d24f30..3d3fd03fa450 100644
1310     --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
1311     +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
1312     @@ -635,43 +635,15 @@ static inline bool is_first_ethertype_ip(struct sk_buff *skb)
1313     return (ethertype == htons(ETH_P_IP) || ethertype == htons(ETH_P_IPV6));
1314     }
1315    
1316     -static __be32 mlx5e_get_fcs(struct sk_buff *skb)
1317     +static u32 mlx5e_get_fcs(const struct sk_buff *skb)
1318     {
1319     - int last_frag_sz, bytes_in_prev, nr_frags;
1320     - u8 *fcs_p1, *fcs_p2;
1321     - skb_frag_t *last_frag;
1322     - __be32 fcs_bytes;
1323     + const void *fcs_bytes;
1324     + u32 _fcs_bytes;
1325    
1326     - if (!skb_is_nonlinear(skb))
1327     - return *(__be32 *)(skb->data + skb->len - ETH_FCS_LEN);
1328     + fcs_bytes = skb_header_pointer(skb, skb->len - ETH_FCS_LEN,
1329     + ETH_FCS_LEN, &_fcs_bytes);
1330    
1331     - nr_frags = skb_shinfo(skb)->nr_frags;
1332     - last_frag = &skb_shinfo(skb)->frags[nr_frags - 1];
1333     - last_frag_sz = skb_frag_size(last_frag);
1334     -
1335     - /* If all FCS data is in last frag */
1336     - if (last_frag_sz >= ETH_FCS_LEN)
1337     - return *(__be32 *)(skb_frag_address(last_frag) +
1338     - last_frag_sz - ETH_FCS_LEN);
1339     -
1340     - fcs_p2 = (u8 *)skb_frag_address(last_frag);
1341     - bytes_in_prev = ETH_FCS_LEN - last_frag_sz;
1342     -
1343     - /* Find where the other part of the FCS is - Linear or another frag */
1344     - if (nr_frags == 1) {
1345     - fcs_p1 = skb_tail_pointer(skb);
1346     - } else {
1347     - skb_frag_t *prev_frag = &skb_shinfo(skb)->frags[nr_frags - 2];
1348     -
1349     - fcs_p1 = skb_frag_address(prev_frag) +
1350     - skb_frag_size(prev_frag);
1351     - }
1352     - fcs_p1 -= bytes_in_prev;
1353     -
1354     - memcpy(&fcs_bytes, fcs_p1, bytes_in_prev);
1355     - memcpy(((u8 *)&fcs_bytes) + bytes_in_prev, fcs_p2, last_frag_sz);
1356     -
1357     - return fcs_bytes;
1358     + return __get_unaligned_cpu32(fcs_bytes);
1359     }
1360    
1361     static inline void mlx5e_handle_csum(struct net_device *netdev,
1362     @@ -693,8 +665,9 @@ static inline void mlx5e_handle_csum(struct net_device *netdev,
1363     skb->ip_summed = CHECKSUM_COMPLETE;
1364     skb->csum = csum_unfold((__force __sum16)cqe->check_sum);
1365     if (unlikely(netdev->features & NETIF_F_RXFCS))
1366     - skb->csum = csum_add(skb->csum,
1367     - (__force __wsum)mlx5e_get_fcs(skb));
1368     + skb->csum = csum_block_add(skb->csum,
1369     + (__force __wsum)mlx5e_get_fcs(skb),
1370     + skb->len - ETH_FCS_LEN);
1371     rq->stats.csum_complete++;
1372     return;
1373     }
1374     diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
1375     index eb91de86202b..5da0b6e11530 100644
1376     --- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c
1377     +++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
1378     @@ -262,7 +262,7 @@ static void eq_pf_process(struct mlx5_eq *eq)
1379     case MLX5_PFAULT_SUBTYPE_WQE:
1380     /* WQE based event */
1381     pfault->type =
1382     - be32_to_cpu(pf_eqe->wqe.pftype_wq) >> 24;
1383     + (be32_to_cpu(pf_eqe->wqe.pftype_wq) >> 24) & 0x7;
1384     pfault->token =
1385     be32_to_cpu(pf_eqe->wqe.token);
1386     pfault->wqe.wq_num =
1387     diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
1388     index e41f28602535..eb666877d1aa 100644
1389     --- a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
1390     +++ b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
1391     @@ -1672,7 +1672,7 @@ qed_iwarp_parse_rx_pkt(struct qed_hwfn *p_hwfn,
1392    
1393     cm_info->local_ip[0] = ntohl(iph->daddr);
1394     cm_info->remote_ip[0] = ntohl(iph->saddr);
1395     - cm_info->ip_version = TCP_IPV4;
1396     + cm_info->ip_version = QED_TCP_IPV4;
1397    
1398     ip_hlen = (iph->ihl) * sizeof(u32);
1399     *payload_len = ntohs(iph->tot_len) - ip_hlen;
1400     @@ -1692,7 +1692,7 @@ qed_iwarp_parse_rx_pkt(struct qed_hwfn *p_hwfn,
1401     cm_info->remote_ip[i] =
1402     ntohl(ip6h->saddr.in6_u.u6_addr32[i]);
1403     }
1404     - cm_info->ip_version = TCP_IPV6;
1405     + cm_info->ip_version = QED_TCP_IPV6;
1406    
1407     ip_hlen = sizeof(*ip6h);
1408     *payload_len = ntohs(ip6h->payload_len);
1409     diff --git a/drivers/net/ethernet/qlogic/qed/qed_roce.c b/drivers/net/ethernet/qlogic/qed/qed_roce.c
1410     index fb7c2d1562ae..bedbf840fd7d 100644
1411     --- a/drivers/net/ethernet/qlogic/qed/qed_roce.c
1412     +++ b/drivers/net/ethernet/qlogic/qed/qed_roce.c
1413     @@ -129,23 +129,16 @@ static void qed_rdma_copy_gids(struct qed_rdma_qp *qp, __le32 *src_gid,
1414    
1415     static enum roce_flavor qed_roce_mode_to_flavor(enum roce_mode roce_mode)
1416     {
1417     - enum roce_flavor flavor;
1418     -
1419     switch (roce_mode) {
1420     case ROCE_V1:
1421     - flavor = PLAIN_ROCE;
1422     - break;
1423     + return PLAIN_ROCE;
1424     case ROCE_V2_IPV4:
1425     - flavor = RROCE_IPV4;
1426     - break;
1427     + return RROCE_IPV4;
1428     case ROCE_V2_IPV6:
1429     - flavor = ROCE_V2_IPV6;
1430     - break;
1431     + return RROCE_IPV6;
1432     default:
1433     - flavor = MAX_ROCE_MODE;
1434     - break;
1435     + return MAX_ROCE_FLAVOR;
1436     }
1437     - return flavor;
1438     }
1439    
1440     void qed_roce_free_cid_pair(struct qed_hwfn *p_hwfn, u16 cid)
1441     diff --git a/drivers/net/ethernet/qlogic/qed/qed_sp_commands.c b/drivers/net/ethernet/qlogic/qed/qed_sp_commands.c
1442     index 46d0c3cb83a5..d7c5965328be 100644
1443     --- a/drivers/net/ethernet/qlogic/qed/qed_sp_commands.c
1444     +++ b/drivers/net/ethernet/qlogic/qed/qed_sp_commands.c
1445     @@ -154,7 +154,7 @@ qed_set_pf_update_tunn_mode(struct qed_tunnel_info *p_tun,
1446     static void qed_set_tunn_cls_info(struct qed_tunnel_info *p_tun,
1447     struct qed_tunnel_info *p_src)
1448     {
1449     - enum tunnel_clss type;
1450     + int type;
1451    
1452     p_tun->b_update_rx_cls = p_src->b_update_rx_cls;
1453     p_tun->b_update_tx_cls = p_src->b_update_tx_cls;
1454     diff --git a/drivers/net/ethernet/qlogic/qed/qed_vf.c b/drivers/net/ethernet/qlogic/qed/qed_vf.c
1455     index 6eb85db69f9a..dd8ebf6d380f 100644
1456     --- a/drivers/net/ethernet/qlogic/qed/qed_vf.c
1457     +++ b/drivers/net/ethernet/qlogic/qed/qed_vf.c
1458     @@ -413,7 +413,6 @@ static int qed_vf_pf_acquire(struct qed_hwfn *p_hwfn)
1459     }
1460    
1461     if (!p_iov->b_pre_fp_hsi &&
1462     - ETH_HSI_VER_MINOR &&
1463     (resp->pfdev_info.minor_fp_hsi < ETH_HSI_VER_MINOR)) {
1464     DP_INFO(p_hwfn,
1465     "PF is using older fastpath HSI; %02x.%02x is configured\n",
1466     @@ -572,7 +571,7 @@ free_p_iov:
1467     static void
1468     __qed_vf_prep_tunn_req_tlv(struct vfpf_update_tunn_param_tlv *p_req,
1469     struct qed_tunn_update_type *p_src,
1470     - enum qed_tunn_clss mask, u8 *p_cls)
1471     + enum qed_tunn_mode mask, u8 *p_cls)
1472     {
1473     if (p_src->b_update_mode) {
1474     p_req->tun_mode_update_mask |= BIT(mask);
1475     @@ -587,7 +586,7 @@ __qed_vf_prep_tunn_req_tlv(struct vfpf_update_tunn_param_tlv *p_req,
1476     static void
1477     qed_vf_prep_tunn_req_tlv(struct vfpf_update_tunn_param_tlv *p_req,
1478     struct qed_tunn_update_type *p_src,
1479     - enum qed_tunn_clss mask,
1480     + enum qed_tunn_mode mask,
1481     u8 *p_cls, struct qed_tunn_update_udp_port *p_port,
1482     u8 *p_update_port, u16 *p_udp_port)
1483     {
1484     diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c
1485     index 929fb8d96ec0..8d979fef5fc7 100644
1486     --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c
1487     +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c
1488     @@ -205,6 +205,9 @@ rx_handler_result_t rmnet_rx_handler(struct sk_buff **pskb)
1489     if (!skb)
1490     return RX_HANDLER_CONSUMED;
1491    
1492     + if (skb->pkt_type == PACKET_LOOPBACK)
1493     + return RX_HANDLER_PASS;
1494     +
1495     dev = skb->dev;
1496     port = rmnet_get_port(dev);
1497    
1498     diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
1499     index f7e540eeb877..1b61ce310132 100644
1500     --- a/drivers/net/ethernet/realtek/r8169.c
1501     +++ b/drivers/net/ethernet/realtek/r8169.c
1502     @@ -7579,17 +7579,15 @@ static int rtl8169_poll(struct napi_struct *napi, int budget)
1503     struct rtl8169_private *tp = container_of(napi, struct rtl8169_private, napi);
1504     struct net_device *dev = tp->dev;
1505     u16 enable_mask = RTL_EVENT_NAPI | tp->event_slow;
1506     - int work_done= 0;
1507     + int work_done;
1508     u16 status;
1509    
1510     status = rtl_get_events(tp);
1511     rtl_ack_events(tp, status & ~tp->event_slow);
1512    
1513     - if (status & RTL_EVENT_NAPI_RX)
1514     - work_done = rtl_rx(dev, tp, (u32) budget);
1515     + work_done = rtl_rx(dev, tp, (u32) budget);
1516    
1517     - if (status & RTL_EVENT_NAPI_TX)
1518     - rtl_tx(dev, tp);
1519     + rtl_tx(dev, tp);
1520    
1521     if (status & tp->event_slow) {
1522     enable_mask &= ~tp->event_slow;
1523     diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
1524     index f5f37bfa1d58..ff2eeddf588e 100644
1525     --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
1526     +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
1527     @@ -133,7 +133,7 @@ static int stmmac_mdio_write(struct mii_bus *bus, int phyaddr, int phyreg,
1528     */
1529     int stmmac_mdio_reset(struct mii_bus *bus)
1530     {
1531     -#if defined(CONFIG_STMMAC_PLATFORM)
1532     +#if IS_ENABLED(CONFIG_STMMAC_PLATFORM)
1533     struct net_device *ndev = bus->priv;
1534     struct stmmac_priv *priv = netdev_priv(ndev);
1535     unsigned int mii_address = priv->hw->mii.addr;
1536     diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
1537     index 6a393b16a1fc..c54a50dbd5ac 100644
1538     --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
1539     +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
1540     @@ -303,7 +303,7 @@ static void stmmac_pci_remove(struct pci_dev *pdev)
1541     pci_disable_device(pdev);
1542     }
1543    
1544     -static int stmmac_pci_suspend(struct device *dev)
1545     +static int __maybe_unused stmmac_pci_suspend(struct device *dev)
1546     {
1547     struct pci_dev *pdev = to_pci_dev(dev);
1548     int ret;
1549     @@ -321,7 +321,7 @@ static int stmmac_pci_suspend(struct device *dev)
1550     return 0;
1551     }
1552    
1553     -static int stmmac_pci_resume(struct device *dev)
1554     +static int __maybe_unused stmmac_pci_resume(struct device *dev)
1555     {
1556     struct pci_dev *pdev = to_pci_dev(dev);
1557     int ret;
1558     diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
1559     index 7a7c5224a336..16a6e1193912 100644
1560     --- a/drivers/net/hamradio/yam.c
1561     +++ b/drivers/net/hamradio/yam.c
1562     @@ -980,6 +980,8 @@ static int yam_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1563     sizeof(struct yamdrv_ioctl_mcs));
1564     if (IS_ERR(ym))
1565     return PTR_ERR(ym);
1566     + if (ym->cmd != SIOCYAMSMCS)
1567     + return -EINVAL;
1568     if (ym->bitrate > YAM_MAXBITRATE) {
1569     kfree(ym);
1570     return -EINVAL;
1571     @@ -995,6 +997,8 @@ static int yam_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1572     if (copy_from_user(&yi, ifr->ifr_data, sizeof(struct yamdrv_ioctl_cfg)))
1573     return -EFAULT;
1574    
1575     + if (yi.cmd != SIOCYAMSCFG)
1576     + return -EINVAL;
1577     if ((yi.cfg.mask & YAM_IOBASE) && netif_running(dev))
1578     return -EINVAL; /* Cannot change this parameter when up */
1579     if ((yi.cfg.mask & YAM_IRQ) && netif_running(dev))
1580     diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
1581     index a174d05a9752..fe76e2c4022a 100644
1582     --- a/drivers/net/phy/phy_device.c
1583     +++ b/drivers/net/phy/phy_device.c
1584     @@ -1641,6 +1641,23 @@ int genphy_config_init(struct phy_device *phydev)
1585     }
1586     EXPORT_SYMBOL(genphy_config_init);
1587    
1588     +/* This is used for the phy device which doesn't support the MMD extended
1589     + * register access, but it does have side effect when we are trying to access
1590     + * the MMD register via indirect method.
1591     + */
1592     +int genphy_read_mmd_unsupported(struct phy_device *phdev, int devad, u16 regnum)
1593     +{
1594     + return -EOPNOTSUPP;
1595     +}
1596     +EXPORT_SYMBOL(genphy_read_mmd_unsupported);
1597     +
1598     +int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum,
1599     + u16 regnum, u16 val)
1600     +{
1601     + return -EOPNOTSUPP;
1602     +}
1603     +EXPORT_SYMBOL(genphy_write_mmd_unsupported);
1604     +
1605     int genphy_suspend(struct phy_device *phydev)
1606     {
1607     int value;
1608     diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
1609     index e4a6ed88b9cf..79f28b9186c6 100644
1610     --- a/drivers/net/phy/phylink.c
1611     +++ b/drivers/net/phy/phylink.c
1612     @@ -561,7 +561,7 @@ void phylink_destroy(struct phylink *pl)
1613     {
1614     if (pl->sfp_bus)
1615     sfp_unregister_upstream(pl->sfp_bus);
1616     - if (!IS_ERR(pl->link_gpio))
1617     + if (!IS_ERR_OR_NULL(pl->link_gpio))
1618     gpiod_put(pl->link_gpio);
1619    
1620     cancel_work_sync(&pl->resolve);
1621     diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
1622     index 9cbe645e3d89..7d38af5ed4b5 100644
1623     --- a/drivers/net/phy/realtek.c
1624     +++ b/drivers/net/phy/realtek.c
1625     @@ -138,6 +138,8 @@ static struct phy_driver realtek_drvs[] = {
1626     .read_status = &genphy_read_status,
1627     .ack_interrupt = &rtl821x_ack_interrupt,
1628     .config_intr = &rtl8211b_config_intr,
1629     + .read_mmd = &genphy_read_mmd_unsupported,
1630     + .write_mmd = &genphy_write_mmd_unsupported,
1631     }, {
1632     .phy_id = 0x001cc914,
1633     .name = "RTL8211DN Gigabit Ethernet",
1634     diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
1635     index 522d2900cd1d..e9fcf6ef716a 100644
1636     --- a/drivers/net/usb/asix_common.c
1637     +++ b/drivers/net/usb/asix_common.c
1638     @@ -607,6 +607,9 @@ int asix_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
1639     struct usbnet *dev = netdev_priv(net);
1640     u8 opt = 0;
1641    
1642     + if (wolinfo->wolopts & ~(WAKE_PHY | WAKE_MAGIC))
1643     + return -EINVAL;
1644     +
1645     if (wolinfo->wolopts & WAKE_PHY)
1646     opt |= AX_MONITOR_LINK;
1647     if (wolinfo->wolopts & WAKE_MAGIC)
1648     diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
1649     index f32261ecd215..0f69b77e8502 100644
1650     --- a/drivers/net/usb/ax88179_178a.c
1651     +++ b/drivers/net/usb/ax88179_178a.c
1652     @@ -566,6 +566,9 @@ ax88179_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
1653     struct usbnet *dev = netdev_priv(net);
1654     u8 opt = 0;
1655    
1656     + if (wolinfo->wolopts & ~(WAKE_PHY | WAKE_MAGIC))
1657     + return -EINVAL;
1658     +
1659     if (wolinfo->wolopts & WAKE_PHY)
1660     opt |= AX_MONITOR_MODE_RWLC;
1661     if (wolinfo->wolopts & WAKE_MAGIC)
1662     diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
1663     index 9e3f632e22f1..50e2e10a9050 100644
1664     --- a/drivers/net/usb/lan78xx.c
1665     +++ b/drivers/net/usb/lan78xx.c
1666     @@ -1375,19 +1375,10 @@ static int lan78xx_set_wol(struct net_device *netdev,
1667     if (ret < 0)
1668     return ret;
1669    
1670     - pdata->wol = 0;
1671     - if (wol->wolopts & WAKE_UCAST)
1672     - pdata->wol |= WAKE_UCAST;
1673     - if (wol->wolopts & WAKE_MCAST)
1674     - pdata->wol |= WAKE_MCAST;
1675     - if (wol->wolopts & WAKE_BCAST)
1676     - pdata->wol |= WAKE_BCAST;
1677     - if (wol->wolopts & WAKE_MAGIC)
1678     - pdata->wol |= WAKE_MAGIC;
1679     - if (wol->wolopts & WAKE_PHY)
1680     - pdata->wol |= WAKE_PHY;
1681     - if (wol->wolopts & WAKE_ARP)
1682     - pdata->wol |= WAKE_ARP;
1683     + if (wol->wolopts & ~WAKE_ALL)
1684     + return -EINVAL;
1685     +
1686     + pdata->wol = wol->wolopts;
1687    
1688     device_set_wakeup_enable(&dev->udev->dev, (bool)wol->wolopts);
1689    
1690     @@ -2517,10 +2508,6 @@ static int lan78xx_open(struct net_device *net)
1691     if (ret < 0)
1692     goto out;
1693    
1694     - ret = lan78xx_reset(dev);
1695     - if (ret < 0)
1696     - goto done;
1697     -
1698     phy_start(net->phydev);
1699    
1700     netif_dbg(dev, ifup, dev->net, "phy initialised successfully");
1701     diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
1702     index 0fa64cc1a011..66beff4d7646 100644
1703     --- a/drivers/net/usb/r8152.c
1704     +++ b/drivers/net/usb/r8152.c
1705     @@ -4497,6 +4497,9 @@ static int rtl8152_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
1706     if (!rtl_can_wakeup(tp))
1707     return -EOPNOTSUPP;
1708    
1709     + if (wol->wolopts & ~WAKE_ANY)
1710     + return -EINVAL;
1711     +
1712     ret = usb_autopm_get_interface(tp->intf);
1713     if (ret < 0)
1714     goto out_set_wol;
1715     diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
1716     index b64b1ee56d2d..ec287c9741e8 100644
1717     --- a/drivers/net/usb/smsc75xx.c
1718     +++ b/drivers/net/usb/smsc75xx.c
1719     @@ -731,6 +731,9 @@ static int smsc75xx_ethtool_set_wol(struct net_device *net,
1720     struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
1721     int ret;
1722    
1723     + if (wolinfo->wolopts & ~SUPPORTED_WAKE)
1724     + return -EINVAL;
1725     +
1726     pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE;
1727    
1728     ret = device_set_wakeup_enable(&dev->udev->dev, pdata->wolopts);
1729     diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
1730     index 309b88acd3d0..99e684e39d35 100644
1731     --- a/drivers/net/usb/smsc95xx.c
1732     +++ b/drivers/net/usb/smsc95xx.c
1733     @@ -774,6 +774,9 @@ static int smsc95xx_ethtool_set_wol(struct net_device *net,
1734     struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
1735     int ret;
1736    
1737     + if (wolinfo->wolopts & ~SUPPORTED_WAKE)
1738     + return -EINVAL;
1739     +
1740     pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE;
1741    
1742     ret = device_set_wakeup_enable(&dev->udev->dev, pdata->wolopts);
1743     diff --git a/drivers/net/usb/sr9800.c b/drivers/net/usb/sr9800.c
1744     index 9277a0f228df..35f39f23d881 100644
1745     --- a/drivers/net/usb/sr9800.c
1746     +++ b/drivers/net/usb/sr9800.c
1747     @@ -421,6 +421,9 @@ sr_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
1748     struct usbnet *dev = netdev_priv(net);
1749     u8 opt = 0;
1750    
1751     + if (wolinfo->wolopts & ~(WAKE_PHY | WAKE_MAGIC))
1752     + return -EINVAL;
1753     +
1754     if (wolinfo->wolopts & WAKE_PHY)
1755     opt |= SR_MONITOR_LINK;
1756     if (wolinfo->wolopts & WAKE_MAGIC)
1757     diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
1758     index 910c46b47769..f528e9ac3413 100644
1759     --- a/drivers/net/virtio_net.c
1760     +++ b/drivers/net/virtio_net.c
1761     @@ -1872,8 +1872,9 @@ static void virtnet_freeze_down(struct virtio_device *vdev)
1762     /* Make sure no work handler is accessing the device */
1763     flush_work(&vi->config_work);
1764    
1765     + netif_tx_lock_bh(vi->dev);
1766     netif_device_detach(vi->dev);
1767     - netif_tx_disable(vi->dev);
1768     + netif_tx_unlock_bh(vi->dev);
1769     cancel_delayed_work_sync(&vi->refill);
1770    
1771     if (netif_running(vi->dev)) {
1772     @@ -1909,7 +1910,9 @@ static int virtnet_restore_up(struct virtio_device *vdev)
1773     }
1774     }
1775    
1776     + netif_tx_lock_bh(vi->dev);
1777     netif_device_attach(vi->dev);
1778     + netif_tx_unlock_bh(vi->dev);
1779     return err;
1780     }
1781    
1782     diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/alive.h b/drivers/net/wireless/intel/iwlwifi/fw/api/alive.h
1783     index 3684a3e180e5..007bfe7656a4 100644
1784     --- a/drivers/net/wireless/intel/iwlwifi/fw/api/alive.h
1785     +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/alive.h
1786     @@ -95,8 +95,8 @@ enum {
1787     #define IWL_ALIVE_FLG_RFKILL BIT(0)
1788    
1789     struct iwl_lmac_alive {
1790     - __le32 ucode_minor;
1791     __le32 ucode_major;
1792     + __le32 ucode_minor;
1793     u8 ver_subtype;
1794     u8 ver_type;
1795     u8 mac;
1796     @@ -113,8 +113,8 @@ struct iwl_lmac_alive {
1797     } __packed; /* UCODE_ALIVE_NTFY_API_S_VER_3 */
1798    
1799     struct iwl_umac_alive {
1800     - __le32 umac_minor; /* UMAC version: minor */
1801     __le32 umac_major; /* UMAC version: major */
1802     + __le32 umac_minor; /* UMAC version: minor */
1803     __le32 error_info_addr; /* SRAM address for UMAC error log */
1804     __le32 dbg_print_buff_addr;
1805     } __packed; /* UMAC_ALIVE_DATA_API_S_VER_2 */
1806     diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
1807     index 2fa7ec466275..839010417241 100644
1808     --- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
1809     +++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
1810     @@ -950,7 +950,20 @@ int iwl_fw_dbg_collect_desc(struct iwl_fw_runtime *fwrt,
1811     if (trigger)
1812     delay = msecs_to_jiffies(le32_to_cpu(trigger->stop_delay));
1813    
1814     - if (WARN(fwrt->trans->state == IWL_TRANS_NO_FW,
1815     + /*
1816     + * If the loading of the FW completed successfully, the next step is to
1817     + * get the SMEM config data. Thus, if fwrt->smem_cfg.num_lmacs is non
1818     + * zero, the FW was already loaded successully. If the state is "NO_FW"
1819     + * in such a case - WARN and exit, since FW may be dead. Otherwise, we
1820     + * can try to collect the data, since FW might just not be fully
1821     + * loaded (no "ALIVE" yet), and the debug data is accessible.
1822     + *
1823     + * Corner case: got the FW alive but crashed before getting the SMEM
1824     + * config. In such a case, due to HW access problems, we might
1825     + * collect garbage.
1826     + */
1827     + if (WARN((fwrt->trans->state == IWL_TRANS_NO_FW) &&
1828     + fwrt->smem_cfg.num_lmacs,
1829     "Can't collect dbg data when FW isn't alive\n"))
1830     return -EIO;
1831    
1832     diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rx.c b/drivers/net/wireless/intel/iwlwifi/mvm/rx.c
1833     index 2d14a58cbdd7..c73e4be9bde3 100644
1834     --- a/drivers/net/wireless/intel/iwlwifi/mvm/rx.c
1835     +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rx.c
1836     @@ -439,7 +439,8 @@ void iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct napi_struct *napi,
1837     rx_status->bw = RATE_INFO_BW_160;
1838     break;
1839     }
1840     - if (rate_n_flags & RATE_MCS_SGI_MSK)
1841     + if (!(rate_n_flags & RATE_MCS_CCK_MSK) &&
1842     + rate_n_flags & RATE_MCS_SGI_MSK)
1843     rx_status->enc_flags |= RX_ENC_FLAG_SHORT_GI;
1844     if (rate_n_flags & RATE_HT_MCS_GF_MSK)
1845     rx_status->enc_flags |= RX_ENC_FLAG_HT_GF;
1846     diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
1847     index e2196dc35dc6..8ba8c70571fb 100644
1848     --- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
1849     +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
1850     @@ -981,7 +981,9 @@ void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi,
1851     rx_status->bw = RATE_INFO_BW_160;
1852     break;
1853     }
1854     - if (rate_n_flags & RATE_MCS_SGI_MSK)
1855     +
1856     + if (!(rate_n_flags & RATE_MCS_CCK_MSK) &&
1857     + rate_n_flags & RATE_MCS_SGI_MSK)
1858     rx_status->enc_flags |= RX_ENC_FLAG_SHORT_GI;
1859     if (rate_n_flags & RATE_HT_MCS_GF_MSK)
1860     rx_status->enc_flags |= RX_ENC_FLAG_HT_GF;
1861     diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
1862     index aafa7aa18fbd..477f9f2f6626 100644
1863     --- a/drivers/net/wireless/mac80211_hwsim.c
1864     +++ b/drivers/net/wireless/mac80211_hwsim.c
1865     @@ -2730,8 +2730,7 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
1866     list_add_tail(&data->list, &hwsim_radios);
1867     spin_unlock_bh(&hwsim_radio_lock);
1868    
1869     - if (idx > 0)
1870     - hwsim_mcast_new_radio(idx, info, param);
1871     + hwsim_mcast_new_radio(idx, info, param);
1872    
1873     return idx;
1874    
1875     diff --git a/drivers/net/wireless/marvell/libertas/if_sdio.c b/drivers/net/wireless/marvell/libertas/if_sdio.c
1876     index 43743c26c071..39bf85d0ade0 100644
1877     --- a/drivers/net/wireless/marvell/libertas/if_sdio.c
1878     +++ b/drivers/net/wireless/marvell/libertas/if_sdio.c
1879     @@ -1317,6 +1317,10 @@ static int if_sdio_suspend(struct device *dev)
1880     if (priv->wol_criteria == EHS_REMOVE_WAKEUP) {
1881     dev_info(dev, "Suspend without wake params -- powering down card\n");
1882     if (priv->fw_ready) {
1883     + ret = lbs_suspend(priv);
1884     + if (ret)
1885     + return ret;
1886     +
1887     priv->power_up_on_resume = true;
1888     if_sdio_power_off(card);
1889     }
1890     diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
1891     index 1a40fc3517a8..6ea95b316256 100644
1892     --- a/drivers/net/xen-netfront.c
1893     +++ b/drivers/net/xen-netfront.c
1894     @@ -1824,7 +1824,7 @@ static int talk_to_netback(struct xenbus_device *dev,
1895     err = xen_net_read_mac(dev, info->netdev->dev_addr);
1896     if (err) {
1897     xenbus_dev_fatal(dev, err, "parsing %s/mac", dev->nodename);
1898     - goto out;
1899     + goto out_unlocked;
1900     }
1901    
1902     rtnl_lock();
1903     @@ -1939,6 +1939,7 @@ abort_transaction_no_dev_fatal:
1904     xennet_destroy_queues(info);
1905     out:
1906     rtnl_unlock();
1907     +out_unlocked:
1908     device_unregister(&dev->dev);
1909     return err;
1910     }
1911     @@ -1964,10 +1965,6 @@ static int xennet_connect(struct net_device *dev)
1912     /* talk_to_netback() sets the correct number of queues */
1913     num_queues = dev->real_num_tx_queues;
1914    
1915     - rtnl_lock();
1916     - netdev_update_features(dev);
1917     - rtnl_unlock();
1918     -
1919     if (dev->reg_state == NETREG_UNINITIALIZED) {
1920     err = register_netdev(dev);
1921     if (err) {
1922     @@ -1977,6 +1974,10 @@ static int xennet_connect(struct net_device *dev)
1923     }
1924     }
1925    
1926     + rtnl_lock();
1927     + netdev_update_features(dev);
1928     + rtnl_unlock();
1929     +
1930     /*
1931     * All public and private state should now be sane. Get
1932     * ready to start sending and receiving packets and give the driver
1933     diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
1934     index 4f2747cd15a6..169dd7127f9e 100644
1935     --- a/drivers/s390/net/qeth_core_main.c
1936     +++ b/drivers/s390/net/qeth_core_main.c
1937     @@ -3001,28 +3001,23 @@ static int qeth_send_startlan(struct qeth_card *card)
1938     return rc;
1939     }
1940    
1941     -static int qeth_default_setadapterparms_cb(struct qeth_card *card,
1942     - struct qeth_reply *reply, unsigned long data)
1943     +static int qeth_setadpparms_inspect_rc(struct qeth_ipa_cmd *cmd)
1944     {
1945     - struct qeth_ipa_cmd *cmd;
1946     -
1947     - QETH_CARD_TEXT(card, 4, "defadpcb");
1948     -
1949     - cmd = (struct qeth_ipa_cmd *) data;
1950     - if (cmd->hdr.return_code == 0)
1951     + if (!cmd->hdr.return_code)
1952     cmd->hdr.return_code =
1953     cmd->data.setadapterparms.hdr.return_code;
1954     - return 0;
1955     + return cmd->hdr.return_code;
1956     }
1957    
1958     static int qeth_query_setadapterparms_cb(struct qeth_card *card,
1959     struct qeth_reply *reply, unsigned long data)
1960     {
1961     - struct qeth_ipa_cmd *cmd;
1962     + struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data;
1963    
1964     QETH_CARD_TEXT(card, 3, "quyadpcb");
1965     + if (qeth_setadpparms_inspect_rc(cmd))
1966     + return 0;
1967    
1968     - cmd = (struct qeth_ipa_cmd *) data;
1969     if (cmd->data.setadapterparms.data.query_cmds_supp.lan_type & 0x7f) {
1970     card->info.link_type =
1971     cmd->data.setadapterparms.data.query_cmds_supp.lan_type;
1972     @@ -3030,7 +3025,7 @@ static int qeth_query_setadapterparms_cb(struct qeth_card *card,
1973     }
1974     card->options.adp.supported_funcs =
1975     cmd->data.setadapterparms.data.query_cmds_supp.supported_cmds;
1976     - return qeth_default_setadapterparms_cb(card, reply, (unsigned long)cmd);
1977     + return 0;
1978     }
1979    
1980     static struct qeth_cmd_buffer *qeth_get_adapter_cmd(struct qeth_card *card,
1981     @@ -3122,22 +3117,20 @@ EXPORT_SYMBOL_GPL(qeth_query_ipassists);
1982     static int qeth_query_switch_attributes_cb(struct qeth_card *card,
1983     struct qeth_reply *reply, unsigned long data)
1984     {
1985     - struct qeth_ipa_cmd *cmd;
1986     - struct qeth_switch_info *sw_info;
1987     + struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data;
1988     struct qeth_query_switch_attributes *attrs;
1989     + struct qeth_switch_info *sw_info;
1990    
1991     QETH_CARD_TEXT(card, 2, "qswiatcb");
1992     - cmd = (struct qeth_ipa_cmd *) data;
1993     - sw_info = (struct qeth_switch_info *)reply->param;
1994     - if (cmd->data.setadapterparms.hdr.return_code == 0) {
1995     - attrs = &cmd->data.setadapterparms.data.query_switch_attributes;
1996     - sw_info->capabilities = attrs->capabilities;
1997     - sw_info->settings = attrs->settings;
1998     - QETH_CARD_TEXT_(card, 2, "%04x%04x", sw_info->capabilities,
1999     - sw_info->settings);
2000     - }
2001     - qeth_default_setadapterparms_cb(card, reply, (unsigned long) cmd);
2002     + if (qeth_setadpparms_inspect_rc(cmd))
2003     + return 0;
2004    
2005     + sw_info = (struct qeth_switch_info *)reply->param;
2006     + attrs = &cmd->data.setadapterparms.data.query_switch_attributes;
2007     + sw_info->capabilities = attrs->capabilities;
2008     + sw_info->settings = attrs->settings;
2009     + QETH_CARD_TEXT_(card, 2, "%04x%04x", sw_info->capabilities,
2010     + sw_info->settings);
2011     return 0;
2012     }
2013    
2014     @@ -4188,16 +4181,13 @@ EXPORT_SYMBOL_GPL(qeth_do_send_packet);
2015     static int qeth_setadp_promisc_mode_cb(struct qeth_card *card,
2016     struct qeth_reply *reply, unsigned long data)
2017     {
2018     - struct qeth_ipa_cmd *cmd;
2019     + struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data;
2020     struct qeth_ipacmd_setadpparms *setparms;
2021    
2022     QETH_CARD_TEXT(card, 4, "prmadpcb");
2023    
2024     - cmd = (struct qeth_ipa_cmd *) data;
2025     setparms = &(cmd->data.setadapterparms);
2026     -
2027     - qeth_default_setadapterparms_cb(card, reply, (unsigned long)cmd);
2028     - if (cmd->hdr.return_code) {
2029     + if (qeth_setadpparms_inspect_rc(cmd)) {
2030     QETH_CARD_TEXT_(card, 4, "prmrc%x", cmd->hdr.return_code);
2031     setparms->data.mode = SET_PROMISC_MODE_OFF;
2032     }
2033     @@ -4267,11 +4257,12 @@ EXPORT_SYMBOL_GPL(qeth_get_stats);
2034     static int qeth_setadpparms_change_macaddr_cb(struct qeth_card *card,
2035     struct qeth_reply *reply, unsigned long data)
2036     {
2037     - struct qeth_ipa_cmd *cmd;
2038     + struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data;
2039    
2040     QETH_CARD_TEXT(card, 4, "chgmaccb");
2041     + if (qeth_setadpparms_inspect_rc(cmd))
2042     + return 0;
2043    
2044     - cmd = (struct qeth_ipa_cmd *) data;
2045     if (!card->options.layer2 ||
2046     !(card->info.mac_bits & QETH_LAYER2_MAC_READ)) {
2047     memcpy(card->dev->dev_addr,
2048     @@ -4279,7 +4270,6 @@ static int qeth_setadpparms_change_macaddr_cb(struct qeth_card *card,
2049     OSA_ADDR_LEN);
2050     card->info.mac_bits |= QETH_LAYER2_MAC_READ;
2051     }
2052     - qeth_default_setadapterparms_cb(card, reply, (unsigned long) cmd);
2053     return 0;
2054     }
2055    
2056     @@ -4310,13 +4300,15 @@ EXPORT_SYMBOL_GPL(qeth_setadpparms_change_macaddr);
2057     static int qeth_setadpparms_set_access_ctrl_cb(struct qeth_card *card,
2058     struct qeth_reply *reply, unsigned long data)
2059     {
2060     - struct qeth_ipa_cmd *cmd;
2061     + struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data;
2062     struct qeth_set_access_ctrl *access_ctrl_req;
2063     int fallback = *(int *)reply->param;
2064    
2065     QETH_CARD_TEXT(card, 4, "setaccb");
2066     + if (cmd->hdr.return_code)
2067     + return 0;
2068     + qeth_setadpparms_inspect_rc(cmd);
2069    
2070     - cmd = (struct qeth_ipa_cmd *) data;
2071     access_ctrl_req = &cmd->data.setadapterparms.data.set_access_ctrl;
2072     QETH_DBF_TEXT_(SETUP, 2, "setaccb");
2073     QETH_DBF_TEXT_(SETUP, 2, "%s", card->gdev->dev.kobj.name);
2074     @@ -4389,7 +4381,6 @@ static int qeth_setadpparms_set_access_ctrl_cb(struct qeth_card *card,
2075     card->options.isolation = card->options.prev_isolation;
2076     break;
2077     }
2078     - qeth_default_setadapterparms_cb(card, reply, (unsigned long) cmd);
2079     return 0;
2080     }
2081    
2082     @@ -4677,14 +4668,15 @@ out:
2083     static int qeth_setadpparms_query_oat_cb(struct qeth_card *card,
2084     struct qeth_reply *reply, unsigned long data)
2085     {
2086     - struct qeth_ipa_cmd *cmd;
2087     + struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *)data;
2088     struct qeth_qoat_priv *priv;
2089     char *resdata;
2090     int resdatalen;
2091    
2092     QETH_CARD_TEXT(card, 3, "qoatcb");
2093     + if (qeth_setadpparms_inspect_rc(cmd))
2094     + return 0;
2095    
2096     - cmd = (struct qeth_ipa_cmd *)data;
2097     priv = (struct qeth_qoat_priv *)reply->param;
2098     resdatalen = cmd->data.setadapterparms.hdr.cmdlength;
2099     resdata = (char *)data + 28;
2100     @@ -4778,21 +4770,18 @@ out:
2101     static int qeth_query_card_info_cb(struct qeth_card *card,
2102     struct qeth_reply *reply, unsigned long data)
2103     {
2104     - struct qeth_ipa_cmd *cmd;
2105     + struct carrier_info *carrier_info = (struct carrier_info *)reply->param;
2106     + struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *)data;
2107     struct qeth_query_card_info *card_info;
2108     - struct carrier_info *carrier_info;
2109    
2110     QETH_CARD_TEXT(card, 2, "qcrdincb");
2111     - carrier_info = (struct carrier_info *)reply->param;
2112     - cmd = (struct qeth_ipa_cmd *)data;
2113     - card_info = &cmd->data.setadapterparms.data.card_info;
2114     - if (cmd->data.setadapterparms.hdr.return_code == 0) {
2115     - carrier_info->card_type = card_info->card_type;
2116     - carrier_info->port_mode = card_info->port_mode;
2117     - carrier_info->port_speed = card_info->port_speed;
2118     - }
2119     + if (qeth_setadpparms_inspect_rc(cmd))
2120     + return 0;
2121    
2122     - qeth_default_setadapterparms_cb(card, reply, (unsigned long) cmd);
2123     + card_info = &cmd->data.setadapterparms.data.card_info;
2124     + carrier_info->card_type = card_info->card_type;
2125     + carrier_info->port_mode = card_info->port_mode;
2126     + carrier_info->port_speed = card_info->port_speed;
2127     return 0;
2128     }
2129    
2130     diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
2131     index 998788a967be..3e38bae6ecde 100644
2132     --- a/drivers/scsi/aacraid/commsup.c
2133     +++ b/drivers/scsi/aacraid/commsup.c
2134     @@ -2506,8 +2506,8 @@ int aac_command_thread(void *data)
2135     /* Synchronize our watches */
2136     if (((NSEC_PER_SEC - (NSEC_PER_SEC / HZ)) > now.tv_nsec)
2137     && (now.tv_nsec > (NSEC_PER_SEC / HZ)))
2138     - difference = (((NSEC_PER_SEC - now.tv_nsec) * HZ)
2139     - + NSEC_PER_SEC / 2) / NSEC_PER_SEC;
2140     + difference = HZ + HZ / 2 -
2141     + now.tv_nsec / (NSEC_PER_SEC / HZ);
2142     else {
2143     if (now.tv_nsec > NSEC_PER_SEC / 2)
2144     ++now.tv_sec;
2145     @@ -2531,6 +2531,10 @@ int aac_command_thread(void *data)
2146     if (kthread_should_stop())
2147     break;
2148    
2149     + /*
2150     + * we probably want usleep_range() here instead of the
2151     + * jiffies computation
2152     + */
2153     schedule_timeout(difference);
2154    
2155     if (kthread_should_stop())
2156     diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
2157     index b491af31a5f8..a06b24a61622 100644
2158     --- a/drivers/scsi/ibmvscsi/ibmvfc.c
2159     +++ b/drivers/scsi/ibmvscsi/ibmvfc.c
2160     @@ -3580,11 +3580,9 @@ static void ibmvfc_tgt_implicit_logout(struct ibmvfc_target *tgt)
2161     static int ibmvfc_adisc_needs_plogi(struct ibmvfc_passthru_mad *mad,
2162     struct ibmvfc_target *tgt)
2163     {
2164     - if (memcmp(&mad->fc_iu.response[2], &tgt->ids.port_name,
2165     - sizeof(tgt->ids.port_name)))
2166     + if (wwn_to_u64((u8 *)&mad->fc_iu.response[2]) != tgt->ids.port_name)
2167     return 1;
2168     - if (memcmp(&mad->fc_iu.response[4], &tgt->ids.node_name,
2169     - sizeof(tgt->ids.node_name)))
2170     + if (wwn_to_u64((u8 *)&mad->fc_iu.response[4]) != tgt->ids.node_name)
2171     return 1;
2172     if (be32_to_cpu(mad->fc_iu.response[6]) != tgt->scsi_id)
2173     return 1;
2174     diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
2175     index 1d42d38f5a45..0e19f6bc24ff 100644
2176     --- a/drivers/scsi/qla2xxx/qla_init.c
2177     +++ b/drivers/scsi/qla2xxx/qla_init.c
2178     @@ -1365,8 +1365,8 @@ qla24xx_abort_sp_done(void *ptr, int res)
2179     srb_t *sp = ptr;
2180     struct srb_iocb *abt = &sp->u.iocb_cmd;
2181    
2182     - del_timer(&sp->u.iocb_cmd.timer);
2183     - complete(&abt->u.abt.comp);
2184     + if (del_timer(&sp->u.iocb_cmd.timer))
2185     + complete(&abt->u.abt.comp);
2186     }
2187    
2188     int
2189     diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
2190     index 6d3091ff9b92..c7b284587365 100644
2191     --- a/drivers/scsi/sd.c
2192     +++ b/drivers/scsi/sd.c
2193     @@ -2498,6 +2498,8 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer)
2194     sector_size = old_sector_size;
2195     goto got_data;
2196     }
2197     + /* Remember that READ CAPACITY(16) succeeded */
2198     + sdp->try_rc_10_first = 0;
2199     }
2200     }
2201    
2202     diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
2203     index 0c6065dba48a..4f27e95efcdd 100644
2204     --- a/drivers/soc/fsl/qbman/qman.c
2205     +++ b/drivers/soc/fsl/qbman/qman.c
2206     @@ -2699,6 +2699,9 @@ static int qman_alloc_range(struct gen_pool *p, u32 *result, u32 cnt)
2207     {
2208     unsigned long addr;
2209    
2210     + if (!p)
2211     + return -ENODEV;
2212     +
2213     addr = gen_pool_alloc(p, cnt);
2214     if (!addr)
2215     return -ENOMEM;
2216     diff --git a/drivers/soc/fsl/qe/ucc.c b/drivers/soc/fsl/qe/ucc.c
2217     index c646d8713861..681f7d4b7724 100644
2218     --- a/drivers/soc/fsl/qe/ucc.c
2219     +++ b/drivers/soc/fsl/qe/ucc.c
2220     @@ -626,7 +626,7 @@ static u32 ucc_get_tdm_sync_shift(enum comm_dir mode, u32 tdm_num)
2221     {
2222     u32 shift;
2223    
2224     - shift = (mode == COMM_DIR_RX) ? RX_SYNC_SHIFT_BASE : RX_SYNC_SHIFT_BASE;
2225     + shift = (mode == COMM_DIR_RX) ? RX_SYNC_SHIFT_BASE : TX_SYNC_SHIFT_BASE;
2226     shift -= tdm_num * 2;
2227    
2228     return shift;
2229     diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c
2230     index 4a22a9f06d96..eb7898353457 100644
2231     --- a/drivers/usb/usbip/vhci_sysfs.c
2232     +++ b/drivers/usb/usbip/vhci_sysfs.c
2233     @@ -34,10 +34,10 @@
2234    
2235     /*
2236     * output example:
2237     - * hub port sta spd dev sockfd local_busid
2238     - * hs 0000 004 000 00000000 3 1-2.3
2239     + * hub port sta spd dev sockfd local_busid
2240     + * hs 0000 004 000 00000000 000003 1-2.3
2241     * ................................................
2242     - * ss 0008 004 000 00000000 4 2-3.4
2243     + * ss 0008 004 000 00000000 000004 2-3.4
2244     * ................................................
2245     *
2246     * Output includes socket fd instead of socket pointer address to avoid
2247     @@ -61,13 +61,13 @@ static void port_show_vhci(char **out, int hub, int port, struct vhci_device *vd
2248     if (vdev->ud.status == VDEV_ST_USED) {
2249     *out += sprintf(*out, "%03u %08x ",
2250     vdev->speed, vdev->devid);
2251     - *out += sprintf(*out, "%u %s",
2252     + *out += sprintf(*out, "%06u %s",
2253     vdev->ud.sockfd,
2254     dev_name(&vdev->udev->dev));
2255    
2256     } else {
2257     *out += sprintf(*out, "000 00000000 ");
2258     - *out += sprintf(*out, "0000000000000000 0-0");
2259     + *out += sprintf(*out, "000000 0-0");
2260     }
2261    
2262     *out += sprintf(*out, "\n");
2263     @@ -165,7 +165,7 @@ static ssize_t status_show(struct device *dev,
2264     int pdev_nr;
2265    
2266     out += sprintf(out,
2267     - "hub port sta spd dev socket local_busid\n");
2268     + "hub port sta spd dev sockfd local_busid\n");
2269    
2270     pdev_nr = status_name_to_id(attr->attr.name);
2271     if (pdev_nr < 0)
2272     diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
2273     index 7ee3167bc083..ffdd4e937d1d 100644
2274     --- a/drivers/vhost/vhost.c
2275     +++ b/drivers/vhost/vhost.c
2276     @@ -30,6 +30,7 @@
2277     #include <linux/sched/mm.h>
2278     #include <linux/sched/signal.h>
2279     #include <linux/interval_tree_generic.h>
2280     +#include <linux/nospec.h>
2281    
2282     #include "vhost.h"
2283    
2284     @@ -1366,6 +1367,7 @@ long vhost_vring_ioctl(struct vhost_dev *d, int ioctl, void __user *argp)
2285     if (idx >= d->nvqs)
2286     return -ENOBUFS;
2287    
2288     + idx = array_index_nospec(idx, d->nvqs);
2289     vq = d->vqs[idx];
2290    
2291     mutex_lock(&vq->mutex);
2292     diff --git a/drivers/video/fbdev/pxa168fb.c b/drivers/video/fbdev/pxa168fb.c
2293     index def3a501acd6..d059d04c63ac 100644
2294     --- a/drivers/video/fbdev/pxa168fb.c
2295     +++ b/drivers/video/fbdev/pxa168fb.c
2296     @@ -712,7 +712,7 @@ static int pxa168fb_probe(struct platform_device *pdev)
2297     /*
2298     * enable controller clock
2299     */
2300     - clk_enable(fbi->clk);
2301     + clk_prepare_enable(fbi->clk);
2302    
2303     pxa168fb_set_par(info);
2304    
2305     @@ -767,7 +767,7 @@ static int pxa168fb_probe(struct platform_device *pdev)
2306     failed_free_cmap:
2307     fb_dealloc_cmap(&info->cmap);
2308     failed_free_clk:
2309     - clk_disable(fbi->clk);
2310     + clk_disable_unprepare(fbi->clk);
2311     failed_free_fbmem:
2312     dma_free_coherent(fbi->dev, info->fix.smem_len,
2313     info->screen_base, fbi->fb_start_dma);
2314     @@ -807,7 +807,7 @@ static int pxa168fb_remove(struct platform_device *pdev)
2315     dma_free_wc(fbi->dev, PAGE_ALIGN(info->fix.smem_len),
2316     info->screen_base, info->fix.smem_start);
2317    
2318     - clk_disable(fbi->clk);
2319     + clk_disable_unprepare(fbi->clk);
2320    
2321     framebuffer_release(info);
2322    
2323     diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
2324     index 473ad5985aa3..47dec283628d 100644
2325     --- a/fs/btrfs/qgroup.c
2326     +++ b/fs/btrfs/qgroup.c
2327     @@ -2603,8 +2603,10 @@ out:
2328     }
2329     btrfs_put_tree_mod_seq(fs_info, &tree_mod_seq_elem);
2330    
2331     - if (done && !ret)
2332     + if (done && !ret) {
2333     ret = 1;
2334     + fs_info->qgroup_rescan_progress.objectid = (u64)-1;
2335     + }
2336     return ret;
2337     }
2338    
2339     diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
2340     index 2cd0b3053439..d01cbca84701 100644
2341     --- a/fs/cifs/inode.c
2342     +++ b/fs/cifs/inode.c
2343     @@ -712,7 +712,7 @@ cgfi_exit:
2344     /* Simple function to return a 64 bit hash of string. Rarely called */
2345     static __u64 simple_hashstr(const char *str)
2346     {
2347     - const __u64 hash_mult = 1125899906842597L; /* a big enough prime */
2348     + const __u64 hash_mult = 1125899906842597ULL; /* a big enough prime */
2349     __u64 hash = 0;
2350    
2351     while (*str)
2352     diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c
2353     index a40f36b1b292..9635df94db7d 100644
2354     --- a/fs/fat/fatent.c
2355     +++ b/fs/fat/fatent.c
2356     @@ -681,6 +681,7 @@ int fat_count_free_clusters(struct super_block *sb)
2357     if (ops->ent_get(&fatent) == FAT_ENT_FREE)
2358     free++;
2359     } while (fat_ent_next(sbi, &fatent));
2360     + cond_resched();
2361     }
2362     sbi->free_clusters = free;
2363     sbi->free_clus_valid = 1;
2364     diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
2365     index 1b1283f07941..824f407df1db 100644
2366     --- a/fs/ocfs2/refcounttree.c
2367     +++ b/fs/ocfs2/refcounttree.c
2368     @@ -2946,6 +2946,7 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle,
2369     if (map_end & (PAGE_SIZE - 1))
2370     to = map_end & (PAGE_SIZE - 1);
2371    
2372     +retry:
2373     page = find_or_create_page(mapping, page_index, GFP_NOFS);
2374     if (!page) {
2375     ret = -ENOMEM;
2376     @@ -2954,11 +2955,18 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle,
2377     }
2378    
2379     /*
2380     - * In case PAGE_SIZE <= CLUSTER_SIZE, This page
2381     - * can't be dirtied before we CoW it out.
2382     + * In case PAGE_SIZE <= CLUSTER_SIZE, we do not expect a dirty
2383     + * page, so write it back.
2384     */
2385     - if (PAGE_SIZE <= OCFS2_SB(sb)->s_clustersize)
2386     - BUG_ON(PageDirty(page));
2387     + if (PAGE_SIZE <= OCFS2_SB(sb)->s_clustersize) {
2388     + if (PageDirty(page)) {
2389     + /*
2390     + * write_on_page will unlock the page on return
2391     + */
2392     + ret = write_one_page(page);
2393     + goto retry;
2394     + }
2395     + }
2396    
2397     if (!PageUptodate(page)) {
2398     ret = block_read_full_page(page, ocfs2_get_block);
2399     diff --git a/include/linux/bpf.h b/include/linux/bpf.h
2400     index 5c5be80ce802..c9d2a1a3ef11 100644
2401     --- a/include/linux/bpf.h
2402     +++ b/include/linux/bpf.h
2403     @@ -27,6 +27,7 @@ struct bpf_map_ops {
2404     void (*map_release)(struct bpf_map *map, struct file *map_file);
2405     void (*map_free)(struct bpf_map *map);
2406     int (*map_get_next_key)(struct bpf_map *map, void *key, void *next_key);
2407     + void (*map_release_uref)(struct bpf_map *map);
2408    
2409     /* funcs callable from userspace and from eBPF programs */
2410     void *(*map_lookup_elem)(struct bpf_map *map, void *key);
2411     @@ -300,7 +301,6 @@ int bpf_stackmap_copy(struct bpf_map *map, void *key, void *value);
2412     int bpf_fd_array_map_update_elem(struct bpf_map *map, struct file *map_file,
2413     void *key, void *value, u64 map_flags);
2414     int bpf_fd_array_map_lookup_elem(struct bpf_map *map, void *key, u32 *value);
2415     -void bpf_fd_array_map_clear(struct bpf_map *map);
2416     int bpf_fd_htab_map_update_elem(struct bpf_map *map, struct file *map_file,
2417     void *key, void *value, u64 map_flags);
2418     int bpf_fd_htab_map_lookup_elem(struct bpf_map *map, void *key, u32 *value);
2419     diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
2420     index 6b79a9bba9a7..4be464a07612 100644
2421     --- a/include/linux/compiler_types.h
2422     +++ b/include/linux/compiler_types.h
2423     @@ -78,6 +78,18 @@ extern void __chk_io_ptr(const volatile void __iomem *);
2424     #include <linux/compiler-clang.h>
2425     #endif
2426    
2427     +/*
2428     + * Some architectures need to provide custom definitions of macros provided
2429     + * by linux/compiler-*.h, and can do so using asm/compiler.h. We include that
2430     + * conditionally rather than using an asm-generic wrapper in order to avoid
2431     + * build failures if any C compilation, which will include this file via an
2432     + * -include argument in c_flags, occurs prior to the asm-generic wrappers being
2433     + * generated.
2434     + */
2435     +#ifdef CONFIG_HAVE_ARCH_COMPILER_H
2436     +#include <asm/compiler.h>
2437     +#endif
2438     +
2439     /*
2440     * Generic compiler-dependent macros required for kernel
2441     * build go below this comment. Actual compiler/compiler version
2442     diff --git a/include/linux/iio/buffer-dma.h b/include/linux/iio/buffer-dma.h
2443     index 767467d886de..67c75372b691 100644
2444     --- a/include/linux/iio/buffer-dma.h
2445     +++ b/include/linux/iio/buffer-dma.h
2446     @@ -141,7 +141,7 @@ int iio_dma_buffer_read(struct iio_buffer *buffer, size_t n,
2447     char __user *user_buffer);
2448     size_t iio_dma_buffer_data_available(struct iio_buffer *buffer);
2449     int iio_dma_buffer_set_bytes_per_datum(struct iio_buffer *buffer, size_t bpd);
2450     -int iio_dma_buffer_set_length(struct iio_buffer *buffer, int length);
2451     +int iio_dma_buffer_set_length(struct iio_buffer *buffer, unsigned int length);
2452     int iio_dma_buffer_request_update(struct iio_buffer *buffer);
2453    
2454     int iio_dma_buffer_init(struct iio_dma_buffer_queue *queue,
2455     diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
2456     index c4d19e77fea8..fb677e4f902d 100644
2457     --- a/include/linux/mlx5/driver.h
2458     +++ b/include/linux/mlx5/driver.h
2459     @@ -1193,25 +1193,9 @@ enum {
2460     };
2461    
2462     static inline const struct cpumask *
2463     -mlx5_get_vector_affinity(struct mlx5_core_dev *dev, int vector)
2464     +mlx5_get_vector_affinity_hint(struct mlx5_core_dev *dev, int vector)
2465     {
2466     - const struct cpumask *mask;
2467     - struct irq_desc *desc;
2468     - unsigned int irq;
2469     - int eqn;
2470     - int err;
2471     -
2472     - err = mlx5_vector2eqn(dev, MLX5_EQ_VEC_COMP_BASE + vector, &eqn, &irq);
2473     - if (err)
2474     - return NULL;
2475     -
2476     - desc = irq_to_desc(irq);
2477     -#ifdef CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK
2478     - mask = irq_data_get_effective_affinity_mask(&desc->irq_data);
2479     -#else
2480     - mask = desc->irq_common_data.affinity;
2481     -#endif
2482     - return mask;
2483     + return dev->priv.irq_info[vector].mask;
2484     }
2485    
2486     #endif /* MLX5_DRIVER_H */
2487     diff --git a/include/linux/phy.h b/include/linux/phy.h
2488     index dca9e926b88f..efc04c2d92c9 100644
2489     --- a/include/linux/phy.h
2490     +++ b/include/linux/phy.h
2491     @@ -879,6 +879,10 @@ static inline int genphy_no_soft_reset(struct phy_device *phydev)
2492     {
2493     return 0;
2494     }
2495     +int genphy_read_mmd_unsupported(struct phy_device *phdev, int devad,
2496     + u16 regnum);
2497     +int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum,
2498     + u16 regnum, u16 val);
2499    
2500     /* Clause 45 PHY */
2501     int genphy_c45_restart_aneg(struct phy_device *phydev);
2502     diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
2503     index f57d0bdf3c9e..a8f55ea4146b 100644
2504     --- a/kernel/bpf/arraymap.c
2505     +++ b/kernel/bpf/arraymap.c
2506     @@ -467,7 +467,7 @@ static u32 prog_fd_array_sys_lookup_elem(void *ptr)
2507     }
2508    
2509     /* decrement refcnt of all bpf_progs that are stored in this map */
2510     -void bpf_fd_array_map_clear(struct bpf_map *map)
2511     +static void bpf_fd_array_map_clear(struct bpf_map *map)
2512     {
2513     struct bpf_array *array = container_of(map, struct bpf_array, map);
2514     int i;
2515     @@ -485,6 +485,7 @@ const struct bpf_map_ops prog_array_map_ops = {
2516     .map_fd_get_ptr = prog_fd_array_get_ptr,
2517     .map_fd_put_ptr = prog_fd_array_put_ptr,
2518     .map_fd_sys_lookup_elem = prog_fd_array_sys_lookup_elem,
2519     + .map_release_uref = bpf_fd_array_map_clear,
2520     };
2521    
2522     static struct bpf_event_entry *bpf_event_entry_gen(struct file *perf_file,
2523     diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c
2524     index 20eaddfa691c..22991e19c01c 100644
2525     --- a/kernel/bpf/sockmap.c
2526     +++ b/kernel/bpf/sockmap.c
2527     @@ -875,7 +875,7 @@ static int sock_map_update_elem(struct bpf_map *map,
2528     return err;
2529     }
2530    
2531     -static void sock_map_release(struct bpf_map *map, struct file *map_file)
2532     +static void sock_map_release(struct bpf_map *map)
2533     {
2534     struct bpf_stab *stab = container_of(map, struct bpf_stab, map);
2535     struct bpf_prog *orig;
2536     @@ -895,7 +895,7 @@ const struct bpf_map_ops sock_map_ops = {
2537     .map_get_next_key = sock_map_get_next_key,
2538     .map_update_elem = sock_map_update_elem,
2539     .map_delete_elem = sock_map_delete_elem,
2540     - .map_release = sock_map_release,
2541     + .map_release_uref = sock_map_release,
2542     };
2543    
2544     BPF_CALL_4(bpf_sock_map_update, struct bpf_sock_ops_kern *, bpf_sock,
2545     diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
2546     index 4e933219fec6..ea22d0b6a9f0 100644
2547     --- a/kernel/bpf/syscall.c
2548     +++ b/kernel/bpf/syscall.c
2549     @@ -214,8 +214,8 @@ static void bpf_map_free_deferred(struct work_struct *work)
2550     static void bpf_map_put_uref(struct bpf_map *map)
2551     {
2552     if (atomic_dec_and_test(&map->usercnt)) {
2553     - if (map->map_type == BPF_MAP_TYPE_PROG_ARRAY)
2554     - bpf_fd_array_map_clear(map);
2555     + if (map->ops->map_release_uref)
2556     + map->ops->map_release_uref(map);
2557     }
2558     }
2559    
2560     diff --git a/kernel/events/core.c b/kernel/events/core.c
2561     index 4dbce29a9313..991af683ef9e 100644
2562     --- a/kernel/events/core.c
2563     +++ b/kernel/events/core.c
2564     @@ -8058,6 +8058,8 @@ void perf_tp_event(u16 event_type, u64 count, void *record, int entry_size,
2565     goto unlock;
2566    
2567     list_for_each_entry_rcu(event, &ctx->event_list, event_entry) {
2568     + if (event->cpu != smp_processor_id())
2569     + continue;
2570     if (event->attr.type != PERF_TYPE_TRACEPOINT)
2571     continue;
2572     if (event->attr.config != entry->type)
2573     @@ -9020,9 +9022,7 @@ static void free_pmu_context(struct pmu *pmu)
2574     if (pmu->task_ctx_nr > perf_invalid_context)
2575     return;
2576    
2577     - mutex_lock(&pmus_lock);
2578     free_percpu(pmu->pmu_cpu_context);
2579     - mutex_unlock(&pmus_lock);
2580     }
2581    
2582     /*
2583     @@ -9278,12 +9278,8 @@ EXPORT_SYMBOL_GPL(perf_pmu_register);
2584    
2585     void perf_pmu_unregister(struct pmu *pmu)
2586     {
2587     - int remove_device;
2588     -
2589     mutex_lock(&pmus_lock);
2590     - remove_device = pmu_bus_running;
2591     list_del_rcu(&pmu->entry);
2592     - mutex_unlock(&pmus_lock);
2593    
2594     /*
2595     * We dereference the pmu list under both SRCU and regular RCU, so
2596     @@ -9295,13 +9291,14 @@ void perf_pmu_unregister(struct pmu *pmu)
2597     free_percpu(pmu->pmu_disable_count);
2598     if (pmu->type >= PERF_TYPE_MAX)
2599     idr_remove(&pmu_idr, pmu->type);
2600     - if (remove_device) {
2601     + if (pmu_bus_running) {
2602     if (pmu->nr_addr_filters)
2603     device_remove_file(pmu->dev, &dev_attr_nr_addr_filters);
2604     device_del(pmu->dev);
2605     put_device(pmu->dev);
2606     }
2607     free_pmu_context(pmu);
2608     + mutex_unlock(&pmus_lock);
2609     }
2610     EXPORT_SYMBOL_GPL(perf_pmu_unregister);
2611    
2612     diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c
2613     index 0e4cd64ad2c0..654977862b06 100644
2614     --- a/kernel/locking/test-ww_mutex.c
2615     +++ b/kernel/locking/test-ww_mutex.c
2616     @@ -260,7 +260,7 @@ static void test_cycle_work(struct work_struct *work)
2617     {
2618     struct test_cycle *cycle = container_of(work, typeof(*cycle), work);
2619     struct ww_acquire_ctx ctx;
2620     - int err;
2621     + int err, erra = 0;
2622    
2623     ww_acquire_init(&ctx, &ww_class);
2624     ww_mutex_lock(&cycle->a_mutex, &ctx);
2625     @@ -270,17 +270,19 @@ static void test_cycle_work(struct work_struct *work)
2626    
2627     err = ww_mutex_lock(cycle->b_mutex, &ctx);
2628     if (err == -EDEADLK) {
2629     + err = 0;
2630     ww_mutex_unlock(&cycle->a_mutex);
2631     ww_mutex_lock_slow(cycle->b_mutex, &ctx);
2632     - err = ww_mutex_lock(&cycle->a_mutex, &ctx);
2633     + erra = ww_mutex_lock(&cycle->a_mutex, &ctx);
2634     }
2635    
2636     if (!err)
2637     ww_mutex_unlock(cycle->b_mutex);
2638     - ww_mutex_unlock(&cycle->a_mutex);
2639     + if (!erra)
2640     + ww_mutex_unlock(&cycle->a_mutex);
2641     ww_acquire_fini(&ctx);
2642    
2643     - cycle->result = err;
2644     + cycle->result = err ?: erra;
2645     }
2646    
2647     static int __test_cycle(unsigned int nthreads)
2648     diff --git a/lib/test_bpf.c b/lib/test_bpf.c
2649     index 64701b4c9900..75ebf2bbc2ee 100644
2650     --- a/lib/test_bpf.c
2651     +++ b/lib/test_bpf.c
2652     @@ -5427,7 +5427,7 @@ static struct bpf_test tests[] = {
2653     {
2654     "BPF_MAXINSNS: Jump, gap, jump, ...",
2655     { },
2656     -#ifdef CONFIG_BPF_JIT_ALWAYS_ON
2657     +#if defined(CONFIG_BPF_JIT_ALWAYS_ON) && defined(CONFIG_X86)
2658     CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
2659     #else
2660     CLASSIC | FLAG_NO_DATA,
2661     diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
2662     index 1fba2a03f8ae..ba24f613c0fc 100644
2663     --- a/net/bluetooth/mgmt.c
2664     +++ b/net/bluetooth/mgmt.c
2665     @@ -2298,9 +2298,8 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data,
2666     /* LE address type */
2667     addr_type = le_addr_type(cp->addr.type);
2668    
2669     - hci_remove_irk(hdev, &cp->addr.bdaddr, addr_type);
2670     -
2671     - err = hci_remove_ltk(hdev, &cp->addr.bdaddr, addr_type);
2672     + /* Abort any ongoing SMP pairing. Removes ltk and irk if they exist. */
2673     + err = smp_cancel_and_remove_pairing(hdev, &cp->addr.bdaddr, addr_type);
2674     if (err < 0) {
2675     err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_UNPAIR_DEVICE,
2676     MGMT_STATUS_NOT_PAIRED, &rp,
2677     @@ -2314,8 +2313,6 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data,
2678     goto done;
2679     }
2680    
2681     - /* Abort any ongoing SMP pairing */
2682     - smp_cancel_pairing(conn);
2683    
2684     /* Defer clearing up the connection parameters until closing to
2685     * give a chance of keeping them if a repairing happens.
2686     diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
2687     index a27704ff13a9..dbcc439fc78b 100644
2688     --- a/net/bluetooth/smp.c
2689     +++ b/net/bluetooth/smp.c
2690     @@ -2410,30 +2410,51 @@ unlock:
2691     return ret;
2692     }
2693    
2694     -void smp_cancel_pairing(struct hci_conn *hcon)
2695     +int smp_cancel_and_remove_pairing(struct hci_dev *hdev, bdaddr_t *bdaddr,
2696     + u8 addr_type)
2697     {
2698     - struct l2cap_conn *conn = hcon->l2cap_data;
2699     + struct hci_conn *hcon;
2700     + struct l2cap_conn *conn;
2701     struct l2cap_chan *chan;
2702     struct smp_chan *smp;
2703     + int err;
2704     +
2705     + err = hci_remove_ltk(hdev, bdaddr, addr_type);
2706     + hci_remove_irk(hdev, bdaddr, addr_type);
2707     +
2708     + hcon = hci_conn_hash_lookup_le(hdev, bdaddr, addr_type);
2709     + if (!hcon)
2710     + goto done;
2711    
2712     + conn = hcon->l2cap_data;
2713     if (!conn)
2714     - return;
2715     + goto done;
2716    
2717     chan = conn->smp;
2718     if (!chan)
2719     - return;
2720     + goto done;
2721    
2722     l2cap_chan_lock(chan);
2723    
2724     smp = chan->data;
2725     if (smp) {
2726     + /* Set keys to NULL to make sure smp_failure() does not try to
2727     + * remove and free already invalidated rcu list entries. */
2728     + smp->ltk = NULL;
2729     + smp->slave_ltk = NULL;
2730     + smp->remote_irk = NULL;
2731     +
2732     if (test_bit(SMP_FLAG_COMPLETE, &smp->flags))
2733     smp_failure(conn, 0);
2734     else
2735     smp_failure(conn, SMP_UNSPECIFIED);
2736     + err = 0;
2737     }
2738    
2739     l2cap_chan_unlock(chan);
2740     +
2741     +done:
2742     + return err;
2743     }
2744    
2745     static int smp_cmd_encrypt_info(struct l2cap_conn *conn, struct sk_buff *skb)
2746     diff --git a/net/bluetooth/smp.h b/net/bluetooth/smp.h
2747     index 0ff6247eaa6c..121edadd5f8d 100644
2748     --- a/net/bluetooth/smp.h
2749     +++ b/net/bluetooth/smp.h
2750     @@ -181,7 +181,8 @@ enum smp_key_pref {
2751     };
2752    
2753     /* SMP Commands */
2754     -void smp_cancel_pairing(struct hci_conn *hcon);
2755     +int smp_cancel_and_remove_pairing(struct hci_dev *hdev, bdaddr_t *bdaddr,
2756     + u8 addr_type);
2757     bool smp_sufficient_security(struct hci_conn *hcon, u8 sec_level,
2758     enum smp_key_pref key_pref);
2759     int smp_conn_security(struct hci_conn *hcon, __u8 sec_level);
2760     diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
2761     index 8dc5c8d69bcd..a813dfe2dc2c 100644
2762     --- a/net/bridge/br_multicast.c
2763     +++ b/net/bridge/br_multicast.c
2764     @@ -1390,7 +1390,14 @@ static void br_multicast_query_received(struct net_bridge *br,
2765     return;
2766    
2767     br_multicast_update_query_timer(br, query, max_delay);
2768     - br_multicast_mark_router(br, port);
2769     +
2770     + /* Based on RFC4541, section 2.1.1 IGMP Forwarding Rules,
2771     + * the arrival port for IGMP Queries where the source address
2772     + * is 0.0.0.0 should not be added to router port list.
2773     + */
2774     + if ((saddr->proto == htons(ETH_P_IP) && saddr->u.ip4) ||
2775     + saddr->proto == htons(ETH_P_IPV6))
2776     + br_multicast_mark_router(br, port);
2777     }
2778    
2779     static int br_ip4_multicast_query(struct net_bridge *br,
2780     diff --git a/net/bridge/br_netfilter_hooks.c b/net/bridge/br_netfilter_hooks.c
2781     index c2eea1b8737a..7582f28ab306 100644
2782     --- a/net/bridge/br_netfilter_hooks.c
2783     +++ b/net/bridge/br_netfilter_hooks.c
2784     @@ -832,7 +832,8 @@ static unsigned int ip_sabotage_in(void *priv,
2785     struct sk_buff *skb,
2786     const struct nf_hook_state *state)
2787     {
2788     - if (skb->nf_bridge && !skb->nf_bridge->in_prerouting) {
2789     + if (skb->nf_bridge && !skb->nf_bridge->in_prerouting &&
2790     + !netif_is_l3_master(skb->dev)) {
2791     state->okfn(state->net, state->sk, skb);
2792     return NF_STOLEN;
2793     }
2794     diff --git a/net/core/datagram.c b/net/core/datagram.c
2795     index 3964c108b169..d8a0774f7608 100644
2796     --- a/net/core/datagram.c
2797     +++ b/net/core/datagram.c
2798     @@ -810,8 +810,9 @@ int skb_copy_and_csum_datagram_msg(struct sk_buff *skb,
2799     return -EINVAL;
2800     }
2801    
2802     - if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE))
2803     - netdev_rx_csum_fault(skb->dev);
2804     + if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE) &&
2805     + !skb->csum_complete_sw)
2806     + netdev_rx_csum_fault(NULL);
2807     }
2808     return 0;
2809     fault:
2810     diff --git a/net/core/ethtool.c b/net/core/ethtool.c
2811     index 0ae5ac5e090f..3469f5053c79 100644
2812     --- a/net/core/ethtool.c
2813     +++ b/net/core/ethtool.c
2814     @@ -2410,13 +2410,17 @@ roll_back:
2815     return ret;
2816     }
2817    
2818     -static int ethtool_set_per_queue(struct net_device *dev, void __user *useraddr)
2819     +static int ethtool_set_per_queue(struct net_device *dev,
2820     + void __user *useraddr, u32 sub_cmd)
2821     {
2822     struct ethtool_per_queue_op per_queue_opt;
2823    
2824     if (copy_from_user(&per_queue_opt, useraddr, sizeof(per_queue_opt)))
2825     return -EFAULT;
2826    
2827     + if (per_queue_opt.sub_command != sub_cmd)
2828     + return -EINVAL;
2829     +
2830     switch (per_queue_opt.sub_command) {
2831     case ETHTOOL_GCOALESCE:
2832     return ethtool_get_per_queue_coalesce(dev, useraddr, &per_queue_opt);
2833     @@ -2787,7 +2791,7 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
2834     rc = ethtool_get_phy_stats(dev, useraddr);
2835     break;
2836     case ETHTOOL_PERQUEUE:
2837     - rc = ethtool_set_per_queue(dev, useraddr);
2838     + rc = ethtool_set_per_queue(dev, useraddr, sub_cmd);
2839     break;
2840     case ETHTOOL_GLINKSETTINGS:
2841     rc = ethtool_get_link_ksettings(dev, useraddr);
2842     diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
2843     index 760364526dc1..c392a77ff788 100644
2844     --- a/net/core/rtnetlink.c
2845     +++ b/net/core/rtnetlink.c
2846     @@ -3080,6 +3080,11 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
2847     return -EINVAL;
2848     }
2849    
2850     + if (dev->type != ARPHRD_ETHER) {
2851     + NL_SET_ERR_MSG(extack, "FDB add only supported for Ethernet devices");
2852     + return -EINVAL;
2853     + }
2854     +
2855     addr = nla_data(tb[NDA_LLADDR]);
2856    
2857     err = fdb_vid_parse(tb[NDA_VLAN], &vid);
2858     @@ -3184,6 +3189,11 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
2859     return -EINVAL;
2860     }
2861    
2862     + if (dev->type != ARPHRD_ETHER) {
2863     + NL_SET_ERR_MSG(extack, "FDB delete only supported for Ethernet devices");
2864     + return -EINVAL;
2865     + }
2866     +
2867     addr = nla_data(tb[NDA_LLADDR]);
2868    
2869     err = fdb_vid_parse(tb[NDA_VLAN], &vid);
2870     diff --git a/net/core/skbuff.c b/net/core/skbuff.c
2871     index 9f80b947f53b..c19a118f9f82 100644
2872     --- a/net/core/skbuff.c
2873     +++ b/net/core/skbuff.c
2874     @@ -1843,8 +1843,9 @@ int pskb_trim_rcsum_slow(struct sk_buff *skb, unsigned int len)
2875     if (skb->ip_summed == CHECKSUM_COMPLETE) {
2876     int delta = skb->len - len;
2877    
2878     - skb->csum = csum_sub(skb->csum,
2879     - skb_checksum(skb, len, delta, 0));
2880     + skb->csum = csum_block_sub(skb->csum,
2881     + skb_checksum(skb, len, delta, 0),
2882     + len);
2883     }
2884     return __pskb_trim(skb, len);
2885     }
2886     diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
2887     index e7227128df2c..cb8fa5d7afe1 100644
2888     --- a/net/ipv4/ip_fragment.c
2889     +++ b/net/ipv4/ip_fragment.c
2890     @@ -720,10 +720,14 @@ struct sk_buff *ip_check_defrag(struct net *net, struct sk_buff *skb, u32 user)
2891     if (ip_is_fragment(&iph)) {
2892     skb = skb_share_check(skb, GFP_ATOMIC);
2893     if (skb) {
2894     - if (!pskb_may_pull(skb, netoff + iph.ihl * 4))
2895     - return skb;
2896     - if (pskb_trim_rcsum(skb, netoff + len))
2897     - return skb;
2898     + if (!pskb_may_pull(skb, netoff + iph.ihl * 4)) {
2899     + kfree_skb(skb);
2900     + return NULL;
2901     + }
2902     + if (pskb_trim_rcsum(skb, netoff + len)) {
2903     + kfree_skb(skb);
2904     + return NULL;
2905     + }
2906     memset(IPCB(skb), 0, sizeof(struct inet_skb_parm));
2907     if (ip_defrag(net, skb, user))
2908     return NULL;
2909     diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
2910     index cbd9c0d8a788..9f314a5e9f27 100644
2911     --- a/net/ipv4/ipmr.c
2912     +++ b/net/ipv4/ipmr.c
2913     @@ -2499,8 +2499,6 @@ static int ipmr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb)
2914     next_entry:
2915     e++;
2916     }
2917     - e = 0;
2918     - s_e = 0;
2919    
2920     spin_lock_bh(&mfc_unres_lock);
2921     list_for_each_entry(mfc, &mrt->mfc_unres_queue, list) {
2922     diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
2923     index dc0ec227b9d2..b89920c0f226 100644
2924     --- a/net/ipv4/udp.c
2925     +++ b/net/ipv4/udp.c
2926     @@ -2045,8 +2045,24 @@ static inline int udp4_csum_init(struct sk_buff *skb, struct udphdr *uh,
2927     /* Note, we are only interested in != 0 or == 0, thus the
2928     * force to int.
2929     */
2930     - return (__force int)skb_checksum_init_zero_check(skb, proto, uh->check,
2931     - inet_compute_pseudo);
2932     + err = (__force int)skb_checksum_init_zero_check(skb, proto, uh->check,
2933     + inet_compute_pseudo);
2934     + if (err)
2935     + return err;
2936     +
2937     + if (skb->ip_summed == CHECKSUM_COMPLETE && !skb->csum_valid) {
2938     + /* If SW calculated the value, we know it's bad */
2939     + if (skb->csum_complete_sw)
2940     + return 1;
2941     +
2942     + /* HW says the value is bad. Let's validate that.
2943     + * skb->csum is no longer the full packet checksum,
2944     + * so don't treat it as such.
2945     + */
2946     + skb_checksum_complete_unset(skb);
2947     + }
2948     +
2949     + return 0;
2950     }
2951    
2952     /* wrapper for udp_queue_rcv_skb tacking care of csum conversion and
2953     diff --git a/net/ipv4/xfrm4_input.c b/net/ipv4/xfrm4_input.c
2954     index bcfc00e88756..f8de2482a529 100644
2955     --- a/net/ipv4/xfrm4_input.c
2956     +++ b/net/ipv4/xfrm4_input.c
2957     @@ -67,6 +67,7 @@ int xfrm4_transport_finish(struct sk_buff *skb, int async)
2958    
2959     if (xo && (xo->flags & XFRM_GRO)) {
2960     skb_mac_header_rebuild(skb);
2961     + skb_reset_transport_header(skb);
2962     return 0;
2963     }
2964    
2965     diff --git a/net/ipv4/xfrm4_mode_transport.c b/net/ipv4/xfrm4_mode_transport.c
2966     index 3d36644890bb..1ad2c2c4e250 100644
2967     --- a/net/ipv4/xfrm4_mode_transport.c
2968     +++ b/net/ipv4/xfrm4_mode_transport.c
2969     @@ -46,7 +46,6 @@ static int xfrm4_transport_output(struct xfrm_state *x, struct sk_buff *skb)
2970     static int xfrm4_transport_input(struct xfrm_state *x, struct sk_buff *skb)
2971     {
2972     int ihl = skb->data - skb_transport_header(skb);
2973     - struct xfrm_offload *xo = xfrm_offload(skb);
2974    
2975     if (skb->transport_header != skb->network_header) {
2976     memmove(skb_transport_header(skb),
2977     @@ -54,8 +53,7 @@ static int xfrm4_transport_input(struct xfrm_state *x, struct sk_buff *skb)
2978     skb->network_header = skb->transport_header;
2979     }
2980     ip_hdr(skb)->tot_len = htons(skb->len + ihl);
2981     - if (!xo || !(xo->flags & XFRM_GRO))
2982     - skb_reset_transport_header(skb);
2983     + skb_reset_transport_header(skb);
2984     return 0;
2985     }
2986    
2987     diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
2988     index 569f7c3f6b95..9ac6f6232294 100644
2989     --- a/net/ipv6/addrconf.c
2990     +++ b/net/ipv6/addrconf.c
2991     @@ -4793,8 +4793,8 @@ static int in6_dump_addrs(struct inet6_dev *idev, struct sk_buff *skb,
2992    
2993     /* unicast address incl. temp addr */
2994     list_for_each_entry(ifa, &idev->addr_list, if_list) {
2995     - if (++ip_idx < s_ip_idx)
2996     - continue;
2997     + if (ip_idx < s_ip_idx)
2998     + goto next;
2999     err = inet6_fill_ifaddr(skb, ifa,
3000     NETLINK_CB(cb->skb).portid,
3001     cb->nlh->nlmsg_seq,
3002     @@ -4803,6 +4803,8 @@ static int in6_dump_addrs(struct inet6_dev *idev, struct sk_buff *skb,
3003     if (err < 0)
3004     break;
3005     nl_dump_check_consistent(cb, nlmsg_hdr(skb));
3006     +next:
3007     + ip_idx++;
3008     }
3009     break;
3010     }
3011     diff --git a/net/ipv6/ip6_checksum.c b/net/ipv6/ip6_checksum.c
3012     index 547515e8450a..377717045f8f 100644
3013     --- a/net/ipv6/ip6_checksum.c
3014     +++ b/net/ipv6/ip6_checksum.c
3015     @@ -88,8 +88,24 @@ int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh, int proto)
3016     * Note, we are only interested in != 0 or == 0, thus the
3017     * force to int.
3018     */
3019     - return (__force int)skb_checksum_init_zero_check(skb, proto, uh->check,
3020     - ip6_compute_pseudo);
3021     + err = (__force int)skb_checksum_init_zero_check(skb, proto, uh->check,
3022     + ip6_compute_pseudo);
3023     + if (err)
3024     + return err;
3025     +
3026     + if (skb->ip_summed == CHECKSUM_COMPLETE && !skb->csum_valid) {
3027     + /* If SW calculated the value, we know it's bad */
3028     + if (skb->csum_complete_sw)
3029     + return 1;
3030     +
3031     + /* HW says the value is bad. Let's validate that.
3032     + * skb->csum is no longer the full packet checksum,
3033     + * so don't treat is as such.
3034     + */
3035     + skb_checksum_complete_unset(skb);
3036     + }
3037     +
3038     + return 0;
3039     }
3040     EXPORT_SYMBOL(udp6_csum_init);
3041    
3042     diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
3043     index 0e9296f44ee4..948f304db0a3 100644
3044     --- a/net/ipv6/ip6_tunnel.c
3045     +++ b/net/ipv6/ip6_tunnel.c
3046     @@ -1185,10 +1185,6 @@ route_lookup:
3047     }
3048     skb_dst_set(skb, dst);
3049    
3050     - if (encap_limit >= 0) {
3051     - init_tel_txopt(&opt, encap_limit);
3052     - ipv6_push_frag_opts(skb, &opt.ops, &proto);
3053     - }
3054     hop_limit = hop_limit ? : ip6_dst_hoplimit(dst);
3055    
3056     /* Calculate max headroom for all the headers and adjust
3057     @@ -1203,6 +1199,11 @@ route_lookup:
3058     if (err)
3059     return err;
3060    
3061     + if (encap_limit >= 0) {
3062     + init_tel_txopt(&opt, encap_limit);
3063     + ipv6_push_frag_opts(skb, &opt.ops, &proto);
3064     + }
3065     +
3066     skb_push(skb, sizeof(struct ipv6hdr));
3067     skb_reset_network_header(skb);
3068     ipv6h = ipv6_hdr(skb);
3069     diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
3070     index d112762b4cb8..bd269e78272a 100644
3071     --- a/net/ipv6/mcast.c
3072     +++ b/net/ipv6/mcast.c
3073     @@ -2412,17 +2412,17 @@ static int ip6_mc_leave_src(struct sock *sk, struct ipv6_mc_socklist *iml,
3074     {
3075     int err;
3076    
3077     - /* callers have the socket lock and rtnl lock
3078     - * so no other readers or writers of iml or its sflist
3079     - */
3080     + write_lock_bh(&iml->sflock);
3081     if (!iml->sflist) {
3082     /* any-source empty exclude case */
3083     - return ip6_mc_del_src(idev, &iml->addr, iml->sfmode, 0, NULL, 0);
3084     + err = ip6_mc_del_src(idev, &iml->addr, iml->sfmode, 0, NULL, 0);
3085     + } else {
3086     + err = ip6_mc_del_src(idev, &iml->addr, iml->sfmode,
3087     + iml->sflist->sl_count, iml->sflist->sl_addr, 0);
3088     + sock_kfree_s(sk, iml->sflist, IP6_SFLSIZE(iml->sflist->sl_max));
3089     + iml->sflist = NULL;
3090     }
3091     - err = ip6_mc_del_src(idev, &iml->addr, iml->sfmode,
3092     - iml->sflist->sl_count, iml->sflist->sl_addr, 0);
3093     - sock_kfree_s(sk, iml->sflist, IP6_SFLSIZE(iml->sflist->sl_max));
3094     - iml->sflist = NULL;
3095     + write_unlock_bh(&iml->sflock);
3096     return err;
3097     }
3098    
3099     diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
3100     index 528218460bc5..5f80e57e93ed 100644
3101     --- a/net/ipv6/ndisc.c
3102     +++ b/net/ipv6/ndisc.c
3103     @@ -1722,10 +1722,9 @@ int ndisc_rcv(struct sk_buff *skb)
3104     return 0;
3105     }
3106    
3107     - memset(NEIGH_CB(skb), 0, sizeof(struct neighbour_cb));
3108     -
3109     switch (msg->icmph.icmp6_type) {
3110     case NDISC_NEIGHBOUR_SOLICITATION:
3111     + memset(NEIGH_CB(skb), 0, sizeof(struct neighbour_cb));
3112     ndisc_recv_ns(skb);
3113     break;
3114    
3115     diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
3116     index 2ed8536e10b6..611d406c4656 100644
3117     --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
3118     +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
3119     @@ -598,8 +598,6 @@ int nf_ct_frag6_gather(struct net *net, struct sk_buff *skb, u32 user)
3120     fq->q.meat == fq->q.len &&
3121     nf_ct_frag6_reasm(fq, skb, dev))
3122     ret = 0;
3123     - else
3124     - skb_dst_drop(skb);
3125    
3126     out_unlock:
3127     spin_unlock_bh(&fq->q.lock);
3128     diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
3129     index 5cee941ab0a9..8d185a0fc5af 100644
3130     --- a/net/ipv6/udp.c
3131     +++ b/net/ipv6/udp.c
3132     @@ -794,11 +794,9 @@ static int udp6_unicast_rcv_skb(struct sock *sk, struct sk_buff *skb,
3133    
3134     ret = udpv6_queue_rcv_skb(sk, skb);
3135    
3136     - /* a return value > 0 means to resubmit the input, but
3137     - * it wants the return to be -protocol, or 0
3138     - */
3139     + /* a return value > 0 means to resubmit the input */
3140     if (ret > 0)
3141     - return -ret;
3142     + return ret;
3143     return 0;
3144     }
3145    
3146     diff --git a/net/ipv6/xfrm6_input.c b/net/ipv6/xfrm6_input.c
3147     index 841f4a07438e..9ef490dddcea 100644
3148     --- a/net/ipv6/xfrm6_input.c
3149     +++ b/net/ipv6/xfrm6_input.c
3150     @@ -59,6 +59,7 @@ int xfrm6_transport_finish(struct sk_buff *skb, int async)
3151    
3152     if (xo && (xo->flags & XFRM_GRO)) {
3153     skb_mac_header_rebuild(skb);
3154     + skb_reset_transport_header(skb);
3155     return -1;
3156     }
3157    
3158     diff --git a/net/ipv6/xfrm6_mode_transport.c b/net/ipv6/xfrm6_mode_transport.c
3159     index 9ad07a91708e..3c29da5defe6 100644
3160     --- a/net/ipv6/xfrm6_mode_transport.c
3161     +++ b/net/ipv6/xfrm6_mode_transport.c
3162     @@ -51,7 +51,6 @@ static int xfrm6_transport_output(struct xfrm_state *x, struct sk_buff *skb)
3163     static int xfrm6_transport_input(struct xfrm_state *x, struct sk_buff *skb)
3164     {
3165     int ihl = skb->data - skb_transport_header(skb);
3166     - struct xfrm_offload *xo = xfrm_offload(skb);
3167    
3168     if (skb->transport_header != skb->network_header) {
3169     memmove(skb_transport_header(skb),
3170     @@ -60,8 +59,7 @@ static int xfrm6_transport_input(struct xfrm_state *x, struct sk_buff *skb)
3171     }
3172     ipv6_hdr(skb)->payload_len = htons(skb->len + ihl -
3173     sizeof(struct ipv6hdr));
3174     - if (!xo || !(xo->flags & XFRM_GRO))
3175     - skb_reset_transport_header(skb);
3176     + skb_reset_transport_header(skb);
3177     return 0;
3178     }
3179    
3180     diff --git a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c
3181     index 8ae87d4ec5ff..29dae7f2ff14 100644
3182     --- a/net/ipv6/xfrm6_output.c
3183     +++ b/net/ipv6/xfrm6_output.c
3184     @@ -170,9 +170,11 @@ static int __xfrm6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
3185    
3186     if (toobig && xfrm6_local_dontfrag(skb)) {
3187     xfrm6_local_rxpmtu(skb, mtu);
3188     + kfree_skb(skb);
3189     return -EMSGSIZE;
3190     } else if (!skb->ignore_df && toobig && skb->sk) {
3191     xfrm_local_error(skb, mtu);
3192     + kfree_skb(skb);
3193     return -EMSGSIZE;
3194     }
3195    
3196     diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
3197     index 5c87f1d3e525..33ea389ee015 100644
3198     --- a/net/l2tp/l2tp_core.c
3199     +++ b/net/l2tp/l2tp_core.c
3200     @@ -808,10 +808,8 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
3201     }
3202     }
3203    
3204     - /* Session data offset is handled differently for L2TPv2 and
3205     - * L2TPv3. For L2TPv2, there is an optional 16-bit value in
3206     - * the header. For L2TPv3, the offset is negotiated using AVPs
3207     - * in the session setup control protocol.
3208     + /* Session data offset is defined only for L2TPv2 and is
3209     + * indicated by an optional 16-bit value in the header.
3210     */
3211     if (tunnel->version == L2TP_HDR_VER_2) {
3212     /* If offset bit set, skip it. */
3213     @@ -819,8 +817,7 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
3214     offset = ntohs(*(__be16 *)ptr);
3215     ptr += 2 + offset;
3216     }
3217     - } else
3218     - ptr += session->offset;
3219     + }
3220    
3221     offset = ptr - optr;
3222     if (!pskb_may_pull(skb, offset))
3223     @@ -1104,8 +1101,6 @@ static int l2tp_build_l2tpv3_header(struct l2tp_session *session, void *buf)
3224     }
3225     bufp += session->l2specific_len;
3226     }
3227     - if (session->offset)
3228     - bufp += session->offset;
3229    
3230     return bufp - optr;
3231     }
3232     @@ -1779,7 +1774,7 @@ void l2tp_session_set_header_len(struct l2tp_session *session, int version)
3233     if (session->send_seq)
3234     session->hdr_len += 4;
3235     } else {
3236     - session->hdr_len = 4 + session->cookie_len + session->l2specific_len + session->offset;
3237     + session->hdr_len = 4 + session->cookie_len + session->l2specific_len;
3238     if (session->tunnel->encap == L2TP_ENCAPTYPE_UDP)
3239     session->hdr_len += 4;
3240     }
3241     @@ -1830,7 +1825,6 @@ struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunn
3242     session->recv_seq = cfg->recv_seq;
3243     session->lns_mode = cfg->lns_mode;
3244     session->reorder_timeout = cfg->reorder_timeout;
3245     - session->offset = cfg->offset;
3246     session->l2specific_type = cfg->l2specific_type;
3247     session->l2specific_len = cfg->l2specific_len;
3248     session->cookie_len = cfg->cookie_len;
3249     diff --git a/net/l2tp/l2tp_core.h b/net/l2tp/l2tp_core.h
3250     index 9e2f1fda1b03..0a58c0754526 100644
3251     --- a/net/l2tp/l2tp_core.h
3252     +++ b/net/l2tp/l2tp_core.h
3253     @@ -59,7 +59,6 @@ struct l2tp_session_cfg {
3254     int debug; /* bitmask of debug message
3255     * categories */
3256     u16 vlan_id; /* VLAN pseudowire only */
3257     - u16 offset; /* offset to payload */
3258     u16 l2specific_len; /* Layer 2 specific length */
3259     u16 l2specific_type; /* Layer 2 specific type */
3260     u8 cookie[8]; /* optional cookie */
3261     @@ -86,8 +85,6 @@ struct l2tp_session {
3262     int cookie_len;
3263     u8 peer_cookie[8];
3264     int peer_cookie_len;
3265     - u16 offset; /* offset from end of L2TP header
3266     - to beginning of data */
3267     u16 l2specific_len;
3268     u16 l2specific_type;
3269     u16 hdr_len;
3270     diff --git a/net/l2tp/l2tp_debugfs.c b/net/l2tp/l2tp_debugfs.c
3271     index 53bae54c4d6e..534cad03b9e9 100644
3272     --- a/net/l2tp/l2tp_debugfs.c
3273     +++ b/net/l2tp/l2tp_debugfs.c
3274     @@ -180,8 +180,8 @@ static void l2tp_dfs_seq_session_show(struct seq_file *m, void *v)
3275     session->lns_mode ? "LNS" : "LAC",
3276     session->debug,
3277     jiffies_to_msecs(session->reorder_timeout));
3278     - seq_printf(m, " offset %hu l2specific %hu/%hu\n",
3279     - session->offset, session->l2specific_type, session->l2specific_len);
3280     + seq_printf(m, " offset 0 l2specific %hu/%hu\n",
3281     + session->l2specific_type, session->l2specific_len);
3282     if (session->cookie_len) {
3283     seq_printf(m, " cookie %02x%02x%02x%02x",
3284     session->cookie[0], session->cookie[1],
3285     diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c
3286     index c28223d8092b..001797ce4084 100644
3287     --- a/net/l2tp/l2tp_netlink.c
3288     +++ b/net/l2tp/l2tp_netlink.c
3289     @@ -549,9 +549,6 @@ static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf
3290     }
3291    
3292     if (tunnel->version > 2) {
3293     - if (info->attrs[L2TP_ATTR_OFFSET])
3294     - cfg.offset = nla_get_u16(info->attrs[L2TP_ATTR_OFFSET]);
3295     -
3296     if (info->attrs[L2TP_ATTR_DATA_SEQ])
3297     cfg.data_seq = nla_get_u8(info->attrs[L2TP_ATTR_DATA_SEQ]);
3298    
3299     diff --git a/net/llc/llc_conn.c b/net/llc/llc_conn.c
3300     index b084fd19ad32..56c3fb5cc805 100644
3301     --- a/net/llc/llc_conn.c
3302     +++ b/net/llc/llc_conn.c
3303     @@ -734,6 +734,7 @@ void llc_sap_add_socket(struct llc_sap *sap, struct sock *sk)
3304     llc_sk(sk)->sap = sap;
3305    
3306     spin_lock_bh(&sap->sk_lock);
3307     + sock_set_flag(sk, SOCK_RCU_FREE);
3308     sap->sk_count++;
3309     sk_nulls_add_node_rcu(sk, laddr_hb);
3310     hlist_add_head(&llc->dev_hash_node, dev_hb);
3311     diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h
3312     index 7e5f271e3c30..4f1c61637ce3 100644
3313     --- a/net/mac80211/mesh.h
3314     +++ b/net/mac80211/mesh.h
3315     @@ -217,7 +217,8 @@ void mesh_rmc_free(struct ieee80211_sub_if_data *sdata);
3316     int mesh_rmc_init(struct ieee80211_sub_if_data *sdata);
3317     void ieee80211s_init(void);
3318     void ieee80211s_update_metric(struct ieee80211_local *local,
3319     - struct sta_info *sta, struct sk_buff *skb);
3320     + struct sta_info *sta,
3321     + struct ieee80211_tx_status *st);
3322     void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata);
3323     void ieee80211_mesh_teardown_sdata(struct ieee80211_sub_if_data *sdata);
3324     int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata);
3325     diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
3326     index 055ea36ff27b..fab0764c315f 100644
3327     --- a/net/mac80211/mesh_hwmp.c
3328     +++ b/net/mac80211/mesh_hwmp.c
3329     @@ -295,15 +295,12 @@ int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata,
3330     }
3331    
3332     void ieee80211s_update_metric(struct ieee80211_local *local,
3333     - struct sta_info *sta, struct sk_buff *skb)
3334     + struct sta_info *sta,
3335     + struct ieee80211_tx_status *st)
3336     {
3337     - struct ieee80211_tx_info *txinfo = IEEE80211_SKB_CB(skb);
3338     - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
3339     + struct ieee80211_tx_info *txinfo = st->info;
3340     int failed;
3341    
3342     - if (!ieee80211_is_data(hdr->frame_control))
3343     - return;
3344     -
3345     failed = !(txinfo->flags & IEEE80211_TX_STAT_ACK);
3346    
3347     /* moving average, scaled to 100.
3348     diff --git a/net/mac80211/status.c b/net/mac80211/status.c
3349     index da7427a41529..bdf131ed5ce8 100644
3350     --- a/net/mac80211/status.c
3351     +++ b/net/mac80211/status.c
3352     @@ -470,11 +470,6 @@ static void ieee80211_report_ack_skb(struct ieee80211_local *local,
3353     if (!skb)
3354     return;
3355    
3356     - if (dropped) {
3357     - dev_kfree_skb_any(skb);
3358     - return;
3359     - }
3360     -
3361     if (info->flags & IEEE80211_TX_INTFL_NL80211_FRAME_TX) {
3362     u64 cookie = IEEE80211_SKB_CB(skb)->ack.cookie;
3363     struct ieee80211_sub_if_data *sdata;
3364     @@ -495,6 +490,8 @@ static void ieee80211_report_ack_skb(struct ieee80211_local *local,
3365     }
3366     rcu_read_unlock();
3367    
3368     + dev_kfree_skb_any(skb);
3369     + } else if (dropped) {
3370     dev_kfree_skb_any(skb);
3371     } else {
3372     /* consumes skb */
3373     @@ -800,7 +797,7 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,
3374    
3375     rate_control_tx_status(local, sband, status);
3376     if (ieee80211_vif_is_mesh(&sta->sdata->vif))
3377     - ieee80211s_update_metric(local, sta, skb);
3378     + ieee80211s_update_metric(local, sta, status);
3379    
3380     if (!(info->flags & IEEE80211_TX_CTL_INJECTED) && acked)
3381     ieee80211_frame_acked(sta, skb);
3382     @@ -961,6 +958,8 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
3383     }
3384    
3385     rate_control_tx_status(local, sband, status);
3386     + if (ieee80211_vif_is_mesh(&sta->sdata->vif))
3387     + ieee80211s_update_metric(local, sta, status);
3388     }
3389    
3390     if (acked || noack_success) {
3391     diff --git a/net/mac80211/tdls.c b/net/mac80211/tdls.c
3392     index 91093d4a2f84..6e7aa65cf345 100644
3393     --- a/net/mac80211/tdls.c
3394     +++ b/net/mac80211/tdls.c
3395     @@ -16,6 +16,7 @@
3396     #include "ieee80211_i.h"
3397     #include "driver-ops.h"
3398     #include "rate.h"
3399     +#include "wme.h"
3400    
3401     /* give usermode some time for retries in setting up the TDLS session */
3402     #define TDLS_PEER_SETUP_TIMEOUT (15 * HZ)
3403     @@ -1006,14 +1007,13 @@ ieee80211_tdls_prep_mgmt_packet(struct wiphy *wiphy, struct net_device *dev,
3404     switch (action_code) {
3405     case WLAN_TDLS_SETUP_REQUEST:
3406     case WLAN_TDLS_SETUP_RESPONSE:
3407     - skb_set_queue_mapping(skb, IEEE80211_AC_BK);
3408     - skb->priority = 2;
3409     + skb->priority = 256 + 2;
3410     break;
3411     default:
3412     - skb_set_queue_mapping(skb, IEEE80211_AC_VI);
3413     - skb->priority = 5;
3414     + skb->priority = 256 + 5;
3415     break;
3416     }
3417     + skb_set_queue_mapping(skb, ieee80211_select_queue(sdata, skb));
3418    
3419     /*
3420     * Set the WLAN_TDLS_TEARDOWN flag to indicate a teardown in progress.
3421     diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
3422     index d8fddd88bf46..a17a56032a21 100644
3423     --- a/net/mac80211/tx.c
3424     +++ b/net/mac80211/tx.c
3425     @@ -1837,7 +1837,7 @@ static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata,
3426     sdata->vif.hw_queue[skb_get_queue_mapping(skb)];
3427    
3428     if (invoke_tx_handlers_early(&tx))
3429     - return false;
3430     + return true;
3431    
3432     if (ieee80211_queue_skb(local, sdata, tx.sta, tx.skb))
3433     return true;
3434     diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
3435     index 4c9c9458374a..f70e9cbf33d5 100644
3436     --- a/net/openvswitch/flow_netlink.c
3437     +++ b/net/openvswitch/flow_netlink.c
3438     @@ -2622,7 +2622,7 @@ static int __ovs_nla_copy_actions(struct net *net, const struct nlattr *attr,
3439     * is already present */
3440     if (mac_proto != MAC_PROTO_NONE)
3441     return -EINVAL;
3442     - mac_proto = MAC_PROTO_NONE;
3443     + mac_proto = MAC_PROTO_ETHERNET;
3444     break;
3445    
3446     case OVS_ACTION_ATTR_POP_ETH:
3447     @@ -2630,7 +2630,7 @@ static int __ovs_nla_copy_actions(struct net *net, const struct nlattr *attr,
3448     return -EINVAL;
3449     if (vlan_tci & htons(VLAN_TAG_PRESENT))
3450     return -EINVAL;
3451     - mac_proto = MAC_PROTO_ETHERNET;
3452     + mac_proto = MAC_PROTO_NONE;
3453     break;
3454    
3455     default:
3456     diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
3457     index e6c2c4f56fb1..71c7f1dd4599 100644
3458     --- a/net/rxrpc/ar-internal.h
3459     +++ b/net/rxrpc/ar-internal.h
3460     @@ -424,8 +424,7 @@ struct rxrpc_connection {
3461     spinlock_t state_lock; /* state-change lock */
3462     enum rxrpc_conn_cache_state cache_state;
3463     enum rxrpc_conn_proto_state state; /* current state of connection */
3464     - u32 local_abort; /* local abort code */
3465     - u32 remote_abort; /* remote abort code */
3466     + u32 abort_code; /* Abort code of connection abort */
3467     int debug_id; /* debug ID for printks */
3468     atomic_t serial; /* packet serial number counter */
3469     unsigned int hi_serial; /* highest serial number received */
3470     @@ -435,6 +434,7 @@ struct rxrpc_connection {
3471     u8 security_size; /* security header size */
3472     u8 security_ix; /* security type */
3473     u8 out_clientflag; /* RXRPC_CLIENT_INITIATED if we are client */
3474     + short error; /* Local error code */
3475     };
3476    
3477     /*
3478     diff --git a/net/rxrpc/call_accept.c b/net/rxrpc/call_accept.c
3479     index 62b1581d44a5..2dd13f5c47c8 100644
3480     --- a/net/rxrpc/call_accept.c
3481     +++ b/net/rxrpc/call_accept.c
3482     @@ -418,11 +418,11 @@ found_service:
3483    
3484     case RXRPC_CONN_REMOTELY_ABORTED:
3485     rxrpc_set_call_completion(call, RXRPC_CALL_REMOTELY_ABORTED,
3486     - conn->remote_abort, -ECONNABORTED);
3487     + conn->abort_code, conn->error);
3488     break;
3489     case RXRPC_CONN_LOCALLY_ABORTED:
3490     rxrpc_abort_call("CON", call, sp->hdr.seq,
3491     - conn->local_abort, -ECONNABORTED);
3492     + conn->abort_code, conn->error);
3493     break;
3494     default:
3495     BUG();
3496     diff --git a/net/rxrpc/conn_event.c b/net/rxrpc/conn_event.c
3497     index 0435c4167a1a..75ec1ad595b7 100644
3498     --- a/net/rxrpc/conn_event.c
3499     +++ b/net/rxrpc/conn_event.c
3500     @@ -117,7 +117,7 @@ static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,
3501    
3502     switch (chan->last_type) {
3503     case RXRPC_PACKET_TYPE_ABORT:
3504     - _proto("Tx ABORT %%%u { %d } [re]", serial, conn->local_abort);
3505     + _proto("Tx ABORT %%%u { %d } [re]", serial, conn->abort_code);
3506     break;
3507     case RXRPC_PACKET_TYPE_ACK:
3508     trace_rxrpc_tx_ack(NULL, serial, chan->last_seq, 0,
3509     @@ -135,13 +135,12 @@ static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,
3510     * pass a connection-level abort onto all calls on that connection
3511     */
3512     static void rxrpc_abort_calls(struct rxrpc_connection *conn,
3513     - enum rxrpc_call_completion compl,
3514     - u32 abort_code, int error)
3515     + enum rxrpc_call_completion compl)
3516     {
3517     struct rxrpc_call *call;
3518     int i;
3519    
3520     - _enter("{%d},%x", conn->debug_id, abort_code);
3521     + _enter("{%d},%x", conn->debug_id, conn->abort_code);
3522    
3523     spin_lock(&conn->channel_lock);
3524    
3525     @@ -153,9 +152,11 @@ static void rxrpc_abort_calls(struct rxrpc_connection *conn,
3526     if (compl == RXRPC_CALL_LOCALLY_ABORTED)
3527     trace_rxrpc_abort("CON", call->cid,
3528     call->call_id, 0,
3529     - abort_code, error);
3530     + conn->abort_code,
3531     + conn->error);
3532     if (rxrpc_set_call_completion(call, compl,
3533     - abort_code, error))
3534     + conn->abort_code,
3535     + conn->error))
3536     rxrpc_notify_socket(call);
3537     }
3538     }
3539     @@ -188,10 +189,12 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
3540     return 0;
3541     }
3542    
3543     + conn->error = error;
3544     + conn->abort_code = abort_code;
3545     conn->state = RXRPC_CONN_LOCALLY_ABORTED;
3546     spin_unlock_bh(&conn->state_lock);
3547    
3548     - rxrpc_abort_calls(conn, RXRPC_CALL_LOCALLY_ABORTED, abort_code, error);
3549     + rxrpc_abort_calls(conn, RXRPC_CALL_LOCALLY_ABORTED);
3550    
3551     msg.msg_name = &conn->params.peer->srx.transport;
3552     msg.msg_namelen = conn->params.peer->srx.transport_len;
3553     @@ -210,7 +213,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
3554     whdr._rsvd = 0;
3555     whdr.serviceId = htons(conn->service_id);
3556    
3557     - word = htonl(conn->local_abort);
3558     + word = htonl(conn->abort_code);
3559    
3560     iov[0].iov_base = &whdr;
3561     iov[0].iov_len = sizeof(whdr);
3562     @@ -221,7 +224,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
3563    
3564     serial = atomic_inc_return(&conn->serial);
3565     whdr.serial = htonl(serial);
3566     - _proto("Tx CONN ABORT %%%u { %d }", serial, conn->local_abort);
3567     + _proto("Tx CONN ABORT %%%u { %d }", serial, conn->abort_code);
3568    
3569     ret = kernel_sendmsg(conn->params.local->socket, &msg, iov, 2, len);
3570     if (ret < 0) {
3571     @@ -289,9 +292,10 @@ static int rxrpc_process_event(struct rxrpc_connection *conn,
3572     abort_code = ntohl(wtmp);
3573     _proto("Rx ABORT %%%u { ac=%d }", sp->hdr.serial, abort_code);
3574    
3575     + conn->error = -ECONNABORTED;
3576     + conn->abort_code = abort_code;
3577     conn->state = RXRPC_CONN_REMOTELY_ABORTED;
3578     - rxrpc_abort_calls(conn, RXRPC_CALL_REMOTELY_ABORTED,
3579     - abort_code, -ECONNABORTED);
3580     + rxrpc_abort_calls(conn, RXRPC_CALL_REMOTELY_ABORTED);
3581     return -ECONNABORTED;
3582    
3583     case RXRPC_PACKET_TYPE_CHALLENGE:
3584     diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
3585     index 5edb636dbc4d..ea506a77f3c8 100644
3586     --- a/net/rxrpc/input.c
3587     +++ b/net/rxrpc/input.c
3588     @@ -216,10 +216,11 @@ static void rxrpc_send_ping(struct rxrpc_call *call, struct sk_buff *skb,
3589     /*
3590     * Apply a hard ACK by advancing the Tx window.
3591     */
3592     -static void rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to,
3593     +static bool rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to,
3594     struct rxrpc_ack_summary *summary)
3595     {
3596     struct sk_buff *skb, *list = NULL;
3597     + bool rot_last = false;
3598     int ix;
3599     u8 annotation;
3600    
3601     @@ -243,15 +244,17 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to,
3602     skb->next = list;
3603     list = skb;
3604    
3605     - if (annotation & RXRPC_TX_ANNO_LAST)
3606     + if (annotation & RXRPC_TX_ANNO_LAST) {
3607     set_bit(RXRPC_CALL_TX_LAST, &call->flags);
3608     + rot_last = true;
3609     + }
3610     if ((annotation & RXRPC_TX_ANNO_MASK) != RXRPC_TX_ANNO_ACK)
3611     summary->nr_rot_new_acks++;
3612     }
3613    
3614     spin_unlock(&call->lock);
3615    
3616     - trace_rxrpc_transmit(call, (test_bit(RXRPC_CALL_TX_LAST, &call->flags) ?
3617     + trace_rxrpc_transmit(call, (rot_last ?
3618     rxrpc_transmit_rotate_last :
3619     rxrpc_transmit_rotate));
3620     wake_up(&call->waitq);
3621     @@ -262,6 +265,8 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to,
3622     skb->next = NULL;
3623     rxrpc_free_skb(skb, rxrpc_skb_tx_freed);
3624     }
3625     +
3626     + return rot_last;
3627     }
3628    
3629     /*
3630     @@ -332,11 +337,11 @@ static bool rxrpc_receiving_reply(struct rxrpc_call *call)
3631     ktime_get_real());
3632     }
3633    
3634     - if (!test_bit(RXRPC_CALL_TX_LAST, &call->flags))
3635     - rxrpc_rotate_tx_window(call, top, &summary);
3636     if (!test_bit(RXRPC_CALL_TX_LAST, &call->flags)) {
3637     - rxrpc_proto_abort("TXL", call, top);
3638     - return false;
3639     + if (!rxrpc_rotate_tx_window(call, top, &summary)) {
3640     + rxrpc_proto_abort("TXL", call, top);
3641     + return false;
3642     + }
3643     }
3644     if (!rxrpc_end_tx_phase(call, true, "ETD"))
3645     return false;
3646     @@ -801,6 +806,16 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb,
3647     rxrpc_propose_ack_respond_to_ack);
3648     }
3649    
3650     + /* Discard any out-of-order or duplicate ACKs. */
3651     + if (before_eq(sp->hdr.serial, call->acks_latest)) {
3652     + _debug("discard ACK %d <= %d",
3653     + sp->hdr.serial, call->acks_latest);
3654     + return;
3655     + }
3656     + call->acks_latest_ts = skb->tstamp;
3657     + call->acks_latest = sp->hdr.serial;
3658     +
3659     + /* Parse rwind and mtu sizes if provided. */
3660     ioffset = offset + nr_acks + 3;
3661     if (skb->len >= ioffset + sizeof(buf.info)) {
3662     if (skb_copy_bits(skb, ioffset, &buf.info, sizeof(buf.info)) < 0)
3663     @@ -822,23 +837,18 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb,
3664     return;
3665     }
3666    
3667     - /* Discard any out-of-order or duplicate ACKs. */
3668     - if (before_eq(sp->hdr.serial, call->acks_latest)) {
3669     - _debug("discard ACK %d <= %d",
3670     - sp->hdr.serial, call->acks_latest);
3671     - return;
3672     - }
3673     - call->acks_latest_ts = skb->tstamp;
3674     - call->acks_latest = sp->hdr.serial;
3675     -
3676     if (before(hard_ack, call->tx_hard_ack) ||
3677     after(hard_ack, call->tx_top))
3678     return rxrpc_proto_abort("AKW", call, 0);
3679     if (nr_acks > call->tx_top - hard_ack)
3680     return rxrpc_proto_abort("AKN", call, 0);
3681    
3682     - if (after(hard_ack, call->tx_hard_ack))
3683     - rxrpc_rotate_tx_window(call, hard_ack, &summary);
3684     + if (after(hard_ack, call->tx_hard_ack)) {
3685     + if (rxrpc_rotate_tx_window(call, hard_ack, &summary)) {
3686     + rxrpc_end_tx_phase(call, false, "ETA");
3687     + return;
3688     + }
3689     + }
3690    
3691     if (nr_acks > 0) {
3692     if (skb_copy_bits(skb, offset, buf.acks, nr_acks) < 0)
3693     @@ -847,11 +857,6 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb,
3694     &summary);
3695     }
3696    
3697     - if (test_bit(RXRPC_CALL_TX_LAST, &call->flags)) {
3698     - rxrpc_end_tx_phase(call, false, "ETA");
3699     - return;
3700     - }
3701     -
3702     if (call->rxtx_annotations[call->tx_top & RXRPC_RXTX_BUFF_MASK] &
3703     RXRPC_TX_ANNO_LAST &&
3704     summary.nr_acks == call->tx_top - hard_ack &&
3705     @@ -873,8 +878,7 @@ static void rxrpc_input_ackall(struct rxrpc_call *call, struct sk_buff *skb)
3706    
3707     _proto("Rx ACKALL %%%u", sp->hdr.serial);
3708    
3709     - rxrpc_rotate_tx_window(call, call->tx_top, &summary);
3710     - if (test_bit(RXRPC_CALL_TX_LAST, &call->flags))
3711     + if (rxrpc_rotate_tx_window(call, call->tx_top, &summary))
3712     rxrpc_end_tx_phase(call, false, "ETL");
3713     }
3714    
3715     diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
3716     index 2f4e1483aced..04a70793c1fe 100644
3717     --- a/net/sched/cls_api.c
3718     +++ b/net/sched/cls_api.c
3719     @@ -31,6 +31,8 @@
3720     #include <net/pkt_sched.h>
3721     #include <net/pkt_cls.h>
3722    
3723     +extern const struct nla_policy rtm_tca_policy[TCA_MAX + 1];
3724     +
3725     /* The list of all installed classifier types */
3726     static LIST_HEAD(tcf_proto_base);
3727    
3728     @@ -559,7 +561,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
3729     replay:
3730     tp_created = 0;
3731    
3732     - err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, NULL, extack);
3733     + err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, rtm_tca_policy, extack);
3734     if (err < 0)
3735     return err;
3736    
3737     @@ -836,7 +838,8 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
3738     if (nlmsg_len(cb->nlh) < sizeof(*tcm))
3739     return skb->len;
3740    
3741     - err = nlmsg_parse(cb->nlh, sizeof(*tcm), tca, TCA_MAX, NULL, NULL);
3742     + err = nlmsg_parse(cb->nlh, sizeof(*tcm), tca, TCA_MAX, rtm_tca_policy,
3743     + NULL);
3744     if (err)
3745     return err;
3746    
3747     diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
3748     index cd69aa067543..691ca96f7460 100644
3749     --- a/net/sched/sch_api.c
3750     +++ b/net/sched/sch_api.c
3751     @@ -1917,7 +1917,8 @@ static int tc_dump_tclass_root(struct Qdisc *root, struct sk_buff *skb,
3752    
3753     if (tcm->tcm_parent) {
3754     q = qdisc_match_from_root(root, TC_H_MAJ(tcm->tcm_parent));
3755     - if (q && tc_dump_tclass_qdisc(q, skb, tcm, cb, t_p, s_t) < 0)
3756     + if (q && q != root &&
3757     + tc_dump_tclass_qdisc(q, skb, tcm, cb, t_p, s_t) < 0)
3758     return -1;
3759     return 0;
3760     }
3761     diff --git a/net/sched/sch_gred.c b/net/sched/sch_gred.c
3762     index bc30f9186ac6..d3105ee8decf 100644
3763     --- a/net/sched/sch_gred.c
3764     +++ b/net/sched/sch_gred.c
3765     @@ -411,7 +411,7 @@ static int gred_change(struct Qdisc *sch, struct nlattr *opt)
3766     if (tb[TCA_GRED_PARMS] == NULL && tb[TCA_GRED_STAB] == NULL) {
3767     if (tb[TCA_GRED_LIMIT] != NULL)
3768     sch->limit = nla_get_u32(tb[TCA_GRED_LIMIT]);
3769     - return gred_change_table_def(sch, opt);
3770     + return gred_change_table_def(sch, tb[TCA_GRED_DPS]);
3771     }
3772    
3773     if (tb[TCA_GRED_PARMS] == NULL ||
3774     diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
3775     index 2a2ab6bfe5d8..3d325b840802 100644
3776     --- a/net/sched/sch_netem.c
3777     +++ b/net/sched/sch_netem.c
3778     @@ -624,6 +624,10 @@ deliver:
3779     skb->next = NULL;
3780     skb->prev = NULL;
3781     skb->tstamp = netem_skb_cb(skb)->tstamp_save;
3782     + /* skb->dev shares skb->rbnode area,
3783     + * we need to restore its value.
3784     + */
3785     + skb->dev = qdisc_dev(sch);
3786    
3787     #ifdef CONFIG_NET_CLS_ACT
3788     /*
3789     diff --git a/net/sctp/socket.c b/net/sctp/socket.c
3790     index 790094311143..d87d56978b4c 100644
3791     --- a/net/sctp/socket.c
3792     +++ b/net/sctp/socket.c
3793     @@ -250,11 +250,10 @@ struct sctp_association *sctp_id2assoc(struct sock *sk, sctp_assoc_t id)
3794    
3795     spin_lock_bh(&sctp_assocs_id_lock);
3796     asoc = (struct sctp_association *)idr_find(&sctp_assocs_id, (int)id);
3797     + if (asoc && (asoc->base.sk != sk || asoc->base.dead))
3798     + asoc = NULL;
3799     spin_unlock_bh(&sctp_assocs_id_lock);
3800    
3801     - if (!asoc || (asoc->base.sk != sk) || asoc->base.dead)
3802     - return NULL;
3803     -
3804     return asoc;
3805     }
3806    
3807     diff --git a/net/socket.c b/net/socket.c
3808     index d27922639a20..a401578f3f28 100644
3809     --- a/net/socket.c
3810     +++ b/net/socket.c
3811     @@ -2879,9 +2879,14 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
3812     copy_in_user(&rxnfc->fs.ring_cookie,
3813     &compat_rxnfc->fs.ring_cookie,
3814     (void __user *)(&rxnfc->fs.location + 1) -
3815     - (void __user *)&rxnfc->fs.ring_cookie) ||
3816     - copy_in_user(&rxnfc->rule_cnt, &compat_rxnfc->rule_cnt,
3817     - sizeof(rxnfc->rule_cnt)))
3818     + (void __user *)&rxnfc->fs.ring_cookie))
3819     + return -EFAULT;
3820     + if (ethcmd == ETHTOOL_GRXCLSRLALL) {
3821     + if (put_user(rule_cnt, &rxnfc->rule_cnt))
3822     + return -EFAULT;
3823     + } else if (copy_in_user(&rxnfc->rule_cnt,
3824     + &compat_rxnfc->rule_cnt,
3825     + sizeof(rxnfc->rule_cnt)))
3826     return -EFAULT;
3827     }
3828    
3829     diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
3830     index 3de415bca391..46e9812d13c0 100644
3831     --- a/net/wireless/nl80211.c
3832     +++ b/net/wireless/nl80211.c
3833     @@ -3480,6 +3480,7 @@ static bool ht_rateset_to_mask(struct ieee80211_supported_band *sband,
3834     return false;
3835    
3836     /* check availability */
3837     + ridx = array_index_nospec(ridx, IEEE80211_HT_MCS_MASK_LEN);
3838     if (sband->ht_cap.mcs.rx_mask[ridx] & rbit)
3839     mcs[ridx] |= rbit;
3840     else
3841     @@ -9719,7 +9720,7 @@ static int cfg80211_cqm_rssi_update(struct cfg80211_registered_device *rdev,
3842     struct wireless_dev *wdev = dev->ieee80211_ptr;
3843     s32 last, low, high;
3844     u32 hyst;
3845     - int i, n;
3846     + int i, n, low_index;
3847     int err;
3848    
3849     /* RSSI reporting disabled? */
3850     @@ -9756,10 +9757,19 @@ static int cfg80211_cqm_rssi_update(struct cfg80211_registered_device *rdev,
3851     if (last < wdev->cqm_config->rssi_thresholds[i])
3852     break;
3853    
3854     - low = i > 0 ?
3855     - (wdev->cqm_config->rssi_thresholds[i - 1] - hyst) : S32_MIN;
3856     - high = i < n ?
3857     - (wdev->cqm_config->rssi_thresholds[i] + hyst - 1) : S32_MAX;
3858     + low_index = i - 1;
3859     + if (low_index >= 0) {
3860     + low_index = array_index_nospec(low_index, n);
3861     + low = wdev->cqm_config->rssi_thresholds[low_index] - hyst;
3862     + } else {
3863     + low = S32_MIN;
3864     + }
3865     + if (i < n) {
3866     + i = array_index_nospec(i, n);
3867     + high = wdev->cqm_config->rssi_thresholds[i] + hyst - 1;
3868     + } else {
3869     + high = S32_MAX;
3870     + }
3871    
3872     return rdev_set_cqm_rssi_range_config(rdev, dev, low, high);
3873     }
3874     diff --git a/net/wireless/reg.c b/net/wireless/reg.c
3875     index 6e94f6934a0e..bd91de416035 100644
3876     --- a/net/wireless/reg.c
3877     +++ b/net/wireless/reg.c
3878     @@ -2170,11 +2170,12 @@ static void reg_process_hint(struct regulatory_request *reg_request)
3879     {
3880     struct wiphy *wiphy = NULL;
3881     enum reg_request_treatment treatment;
3882     + enum nl80211_reg_initiator initiator = reg_request->initiator;
3883    
3884     if (reg_request->wiphy_idx != WIPHY_IDX_INVALID)
3885     wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx);
3886    
3887     - switch (reg_request->initiator) {
3888     + switch (initiator) {
3889     case NL80211_REGDOM_SET_BY_CORE:
3890     treatment = reg_process_hint_core(reg_request);
3891     break;
3892     @@ -2192,7 +2193,7 @@ static void reg_process_hint(struct regulatory_request *reg_request)
3893     treatment = reg_process_hint_country_ie(wiphy, reg_request);
3894     break;
3895     default:
3896     - WARN(1, "invalid initiator %d\n", reg_request->initiator);
3897     + WARN(1, "invalid initiator %d\n", initiator);
3898     goto out_free;
3899     }
3900    
3901     @@ -2207,7 +2208,7 @@ static void reg_process_hint(struct regulatory_request *reg_request)
3902     */
3903     if (treatment == REG_REQ_ALREADY_SET && wiphy &&
3904     wiphy->regulatory_flags & REGULATORY_STRICT_REG) {
3905     - wiphy_update_regulatory(wiphy, reg_request->initiator);
3906     + wiphy_update_regulatory(wiphy, initiator);
3907     wiphy_all_share_dfs_chan_state(wiphy);
3908     reg_check_channels();
3909     }
3910     @@ -2384,6 +2385,7 @@ static int regulatory_hint_core(const char *alpha2)
3911     request->alpha2[0] = alpha2[0];
3912     request->alpha2[1] = alpha2[1];
3913     request->initiator = NL80211_REGDOM_SET_BY_CORE;
3914     + request->wiphy_idx = WIPHY_IDX_INVALID;
3915    
3916     queue_regulatory_request(request);
3917    
3918     diff --git a/net/wireless/scan.c b/net/wireless/scan.c
3919     index f6c5fe482506..5ed0ed0559dc 100644
3920     --- a/net/wireless/scan.c
3921     +++ b/net/wireless/scan.c
3922     @@ -1055,13 +1055,23 @@ cfg80211_bss_update(struct cfg80211_registered_device *rdev,
3923     return NULL;
3924     }
3925    
3926     +/*
3927     + * Update RX channel information based on the available frame payload
3928     + * information. This is mainly for the 2.4 GHz band where frames can be received
3929     + * from neighboring channels and the Beacon frames use the DSSS Parameter Set
3930     + * element to indicate the current (transmitting) channel, but this might also
3931     + * be needed on other bands if RX frequency does not match with the actual
3932     + * operating channel of a BSS.
3933     + */
3934     static struct ieee80211_channel *
3935     cfg80211_get_bss_channel(struct wiphy *wiphy, const u8 *ie, size_t ielen,
3936     - struct ieee80211_channel *channel)
3937     + struct ieee80211_channel *channel,
3938     + enum nl80211_bss_scan_width scan_width)
3939     {
3940     const u8 *tmp;
3941     u32 freq;
3942     int channel_number = -1;
3943     + struct ieee80211_channel *alt_channel;
3944    
3945     tmp = cfg80211_find_ie(WLAN_EID_DS_PARAMS, ie, ielen);
3946     if (tmp && tmp[1] == 1) {
3947     @@ -1075,16 +1085,45 @@ cfg80211_get_bss_channel(struct wiphy *wiphy, const u8 *ie, size_t ielen,
3948     }
3949     }
3950    
3951     - if (channel_number < 0)
3952     + if (channel_number < 0) {
3953     + /* No channel information in frame payload */
3954     return channel;
3955     + }
3956    
3957     freq = ieee80211_channel_to_frequency(channel_number, channel->band);
3958     - channel = ieee80211_get_channel(wiphy, freq);
3959     - if (!channel)
3960     - return NULL;
3961     - if (channel->flags & IEEE80211_CHAN_DISABLED)
3962     + alt_channel = ieee80211_get_channel(wiphy, freq);
3963     + if (!alt_channel) {
3964     + if (channel->band == NL80211_BAND_2GHZ) {
3965     + /*
3966     + * Better not allow unexpected channels when that could
3967     + * be going beyond the 1-11 range (e.g., discovering
3968     + * BSS on channel 12 when radio is configured for
3969     + * channel 11.
3970     + */
3971     + return NULL;
3972     + }
3973     +
3974     + /* No match for the payload channel number - ignore it */
3975     + return channel;
3976     + }
3977     +
3978     + if (scan_width == NL80211_BSS_CHAN_WIDTH_10 ||
3979     + scan_width == NL80211_BSS_CHAN_WIDTH_5) {
3980     + /*
3981     + * Ignore channel number in 5 and 10 MHz channels where there
3982     + * may not be an n:1 or 1:n mapping between frequencies and
3983     + * channel numbers.
3984     + */
3985     + return channel;
3986     + }
3987     +
3988     + /*
3989     + * Use the channel determined through the payload channel number
3990     + * instead of the RX channel reported by the driver.
3991     + */
3992     + if (alt_channel->flags & IEEE80211_CHAN_DISABLED)
3993     return NULL;
3994     - return channel;
3995     + return alt_channel;
3996     }
3997    
3998     /* Returned bss is reference counted and must be cleaned up appropriately. */
3999     @@ -1109,7 +1148,8 @@ cfg80211_inform_bss_data(struct wiphy *wiphy,
4000     (data->signal < 0 || data->signal > 100)))
4001     return NULL;
4002    
4003     - channel = cfg80211_get_bss_channel(wiphy, ie, ielen, data->chan);
4004     + channel = cfg80211_get_bss_channel(wiphy, ie, ielen, data->chan,
4005     + data->scan_width);
4006     if (!channel)
4007     return NULL;
4008    
4009     @@ -1207,7 +1247,7 @@ cfg80211_inform_bss_frame_data(struct wiphy *wiphy,
4010     return NULL;
4011    
4012     channel = cfg80211_get_bss_channel(wiphy, mgmt->u.beacon.variable,
4013     - ielen, data->chan);
4014     + ielen, data->chan, data->scan_width);
4015     if (!channel)
4016     return NULL;
4017    
4018     diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
4019     index 9f492dc417d5..8e75319dd9c0 100644
4020     --- a/net/xfrm/xfrm_input.c
4021     +++ b/net/xfrm/xfrm_input.c
4022     @@ -453,6 +453,7 @@ resume:
4023     XFRM_INC_STATS(net, LINUX_MIB_XFRMINHDRERROR);
4024     goto drop;
4025     }
4026     + crypto_done = false;
4027     } while (!err);
4028    
4029     err = xfrm_rcv_cb(skb, family, x->type->proto, 0);
4030     diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
4031     index 35610cc881a9..c47660fba498 100644
4032     --- a/net/xfrm/xfrm_output.c
4033     +++ b/net/xfrm/xfrm_output.c
4034     @@ -101,6 +101,10 @@ static int xfrm_output_one(struct sk_buff *skb, int err)
4035     spin_unlock_bh(&x->lock);
4036    
4037     skb_dst_force(skb);
4038     + if (!skb_dst(skb)) {
4039     + XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR);
4040     + goto error_nolock;
4041     + }
4042    
4043     if (xfrm_offload(skb)) {
4044     x->type_offload->encap(x, skb);
4045     diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
4046     index 2fb7a78308e1..37c32e73aaef 100644
4047     --- a/net/xfrm/xfrm_policy.c
4048     +++ b/net/xfrm/xfrm_policy.c
4049     @@ -2550,6 +2550,10 @@ int __xfrm_route_forward(struct sk_buff *skb, unsigned short family)
4050     }
4051    
4052     skb_dst_force(skb);
4053     + if (!skb_dst(skb)) {
4054     + XFRM_INC_STATS(net, LINUX_MIB_XFRMFWDHDRERROR);
4055     + return 0;
4056     + }
4057    
4058     dst = xfrm_lookup(net, skb_dst(skb), &fl, NULL, XFRM_LOOKUP_QUEUE);
4059     if (IS_ERR(dst)) {
4060     diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
4061     index 5554d28a32eb..4e8319766f2b 100644
4062     --- a/net/xfrm/xfrm_user.c
4063     +++ b/net/xfrm/xfrm_user.c
4064     @@ -151,10 +151,16 @@ static int verify_newsa_info(struct xfrm_usersa_info *p,
4065     err = -EINVAL;
4066     switch (p->family) {
4067     case AF_INET:
4068     + if (p->sel.prefixlen_d > 32 || p->sel.prefixlen_s > 32)
4069     + goto out;
4070     +
4071     break;
4072    
4073     case AF_INET6:
4074     #if IS_ENABLED(CONFIG_IPV6)
4075     + if (p->sel.prefixlen_d > 128 || p->sel.prefixlen_s > 128)
4076     + goto out;
4077     +
4078     break;
4079     #else
4080     err = -EAFNOSUPPORT;
4081     @@ -1353,10 +1359,16 @@ static int verify_newpolicy_info(struct xfrm_userpolicy_info *p)
4082    
4083     switch (p->sel.family) {
4084     case AF_INET:
4085     + if (p->sel.prefixlen_d > 32 || p->sel.prefixlen_s > 32)
4086     + return -EINVAL;
4087     +
4088     break;
4089    
4090     case AF_INET6:
4091     #if IS_ENABLED(CONFIG_IPV6)
4092     + if (p->sel.prefixlen_d > 128 || p->sel.prefixlen_s > 128)
4093     + return -EINVAL;
4094     +
4095     break;
4096     #else
4097     return -EAFNOSUPPORT;
4098     @@ -1437,6 +1449,9 @@ static int validate_tmpl(int nr, struct xfrm_user_tmpl *ut, u16 family)
4099     (ut[i].family != prev_family))
4100     return -EINVAL;
4101    
4102     + if (ut[i].mode >= XFRM_MODE_MAX)
4103     + return -EINVAL;
4104     +
4105     prev_family = ut[i].family;
4106    
4107     switch (ut[i].family) {
4108     diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
4109     index 126e3f2e1ed7..2b0adeb5fc42 100644
4110     --- a/scripts/kconfig/zconf.y
4111     +++ b/scripts/kconfig/zconf.y
4112     @@ -31,7 +31,7 @@ struct symbol *symbol_hash[SYMBOL_HASHSIZE];
4113     static struct menu *current_menu, *current_entry;
4114    
4115     %}
4116     -%expect 31
4117     +%expect 30
4118    
4119     %union
4120     {
4121     @@ -112,7 +112,7 @@ start: mainmenu_stmt stmt_list | no_mainmenu_stmt stmt_list;
4122    
4123     /* mainmenu entry */
4124    
4125     -mainmenu_stmt: T_MAINMENU prompt nl
4126     +mainmenu_stmt: T_MAINMENU prompt T_EOL
4127     {
4128     menu_add_prompt(P_MENU, $2, NULL);
4129     };
4130     diff --git a/sound/usb/usx2y/usb_stream.c b/sound/usb/usx2y/usb_stream.c
4131     index e229abd21652..b0f8979ff2d2 100644
4132     --- a/sound/usb/usx2y/usb_stream.c
4133     +++ b/sound/usb/usx2y/usb_stream.c
4134     @@ -56,7 +56,7 @@ check:
4135     lb, s->period_size);
4136     }
4137    
4138     -static void init_pipe_urbs(struct usb_stream_kernel *sk, unsigned use_packsize,
4139     +static int init_pipe_urbs(struct usb_stream_kernel *sk, unsigned use_packsize,
4140     struct urb **urbs, char *transfer,
4141     struct usb_device *dev, int pipe)
4142     {
4143     @@ -77,6 +77,8 @@ static void init_pipe_urbs(struct usb_stream_kernel *sk, unsigned use_packsize,
4144     urb->interval = 1;
4145     if (usb_pipeout(pipe))
4146     continue;
4147     + if (usb_urb_ep_type_check(urb))
4148     + return -EINVAL;
4149    
4150     urb->transfer_buffer_length = transfer_length;
4151     desc = urb->iso_frame_desc;
4152     @@ -87,9 +89,11 @@ static void init_pipe_urbs(struct usb_stream_kernel *sk, unsigned use_packsize,
4153     desc[p].length = maxpacket;
4154     }
4155     }
4156     +
4157     + return 0;
4158     }
4159    
4160     -static void init_urbs(struct usb_stream_kernel *sk, unsigned use_packsize,
4161     +static int init_urbs(struct usb_stream_kernel *sk, unsigned use_packsize,
4162     struct usb_device *dev, int in_pipe, int out_pipe)
4163     {
4164     struct usb_stream *s = sk->s;
4165     @@ -103,9 +107,12 @@ static void init_urbs(struct usb_stream_kernel *sk, unsigned use_packsize,
4166     sk->outurb[u] = usb_alloc_urb(sk->n_o_ps, GFP_KERNEL);
4167     }
4168    
4169     - init_pipe_urbs(sk, use_packsize, sk->inurb, indata, dev, in_pipe);
4170     - init_pipe_urbs(sk, use_packsize, sk->outurb, sk->write_page, dev,
4171     - out_pipe);
4172     + if (init_pipe_urbs(sk, use_packsize, sk->inurb, indata, dev, in_pipe) ||
4173     + init_pipe_urbs(sk, use_packsize, sk->outurb, sk->write_page, dev,
4174     + out_pipe))
4175     + return -EINVAL;
4176     +
4177     + return 0;
4178     }
4179    
4180    
4181     @@ -226,7 +233,11 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk,
4182     else
4183     sk->freqn = get_usb_high_speed_rate(sample_rate);
4184    
4185     - init_urbs(sk, use_packsize, dev, in_pipe, out_pipe);
4186     + if (init_urbs(sk, use_packsize, dev, in_pipe, out_pipe) < 0) {
4187     + usb_stream_free(sk);
4188     + return NULL;
4189     + }
4190     +
4191     sk->s->state = usb_stream_stopped;
4192     out:
4193     return sk->s;
4194     diff --git a/tools/perf/Makefile b/tools/perf/Makefile
4195     index 225454416ed5..7902a5681fc8 100644
4196     --- a/tools/perf/Makefile
4197     +++ b/tools/perf/Makefile
4198     @@ -84,10 +84,10 @@ endif # has_clean
4199     endif # MAKECMDGOALS
4200    
4201     #
4202     -# The clean target is not really parallel, don't print the jobs info:
4203     +# Explicitly disable parallelism for the clean target.
4204     #
4205     clean:
4206     - $(make)
4207     + $(make) -j1
4208    
4209     #
4210     # The build-test target is not really parallel, don't print the jobs info,
4211     diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
4212     index 5966f1f9b160..1c9bc3516f8b 100644
4213     --- a/tools/perf/tests/builtin-test.c
4214     +++ b/tools/perf/tests/builtin-test.c
4215     @@ -375,7 +375,7 @@ static int test_and_print(struct test *t, bool force_skip, int subtest)
4216     if (!t->subtest.get_nr)
4217     pr_debug("%s:", t->desc);
4218     else
4219     - pr_debug("%s subtest %d:", t->desc, subtest);
4220     + pr_debug("%s subtest %d:", t->desc, subtest + 1);
4221    
4222     switch (err) {
4223     case TEST_OK:
4224     @@ -589,7 +589,7 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
4225     for (subi = 0; subi < subn; subi++) {
4226     pr_info("%2d.%1d: %-*s:", i, subi + 1, subw,
4227     t->subtest.get_desc(subi));
4228     - err = test_and_print(t, skip, subi + 1);
4229     + err = test_and_print(t, skip, subi);
4230     if (err != TEST_OK && t->subtest.skip_if_fail)
4231     skip = true;
4232     }
4233     diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py
4234     index da4df7fd43a2..23f1bf175179 100644
4235     --- a/tools/perf/util/setup.py
4236     +++ b/tools/perf/util/setup.py
4237     @@ -27,7 +27,7 @@ class install_lib(_install_lib):
4238    
4239     cflags = getenv('CFLAGS', '').split()
4240     # switch off several checks (need to be at the end of cflags list)
4241     -cflags += ['-fno-strict-aliasing', '-Wno-write-strings', '-Wno-unused-parameter' ]
4242     +cflags += ['-fno-strict-aliasing', '-Wno-write-strings', '-Wno-unused-parameter', '-Wno-redundant-decls' ]
4243     if cc != "clang":
4244     cflags += ['-Wno-cast-function-type' ]
4245    
4246     diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
4247     index bef419d4266d..3ad0b3a3317b 100644
4248     --- a/tools/testing/nvdimm/test/nfit.c
4249     +++ b/tools/testing/nvdimm/test/nfit.c
4250     @@ -1589,6 +1589,7 @@ static int nfit_ctl_test(struct device *dev)
4251     unsigned long mask, cmd_size, offset;
4252     union {
4253     struct nd_cmd_get_config_size cfg_size;
4254     + struct nd_cmd_clear_error clear_err;
4255     struct nd_cmd_ars_status ars_stat;
4256     struct nd_cmd_ars_cap ars_cap;
4257     char buf[sizeof(struct nd_cmd_ars_status)
4258     @@ -1767,6 +1768,23 @@ static int nfit_ctl_test(struct device *dev)
4259     return -EIO;
4260     }
4261    
4262     + /* test clear error */
4263     + cmd_size = sizeof(cmds.clear_err);
4264     + cmds.clear_err = (struct nd_cmd_clear_error) {
4265     + .length = 512,
4266     + .cleared = 512,
4267     + };
4268     + rc = setup_result(cmds.buf, cmd_size);
4269     + if (rc)
4270     + return rc;
4271     + rc = acpi_nfit_ctl(&acpi_desc->nd_desc, NULL, ND_CMD_CLEAR_ERROR,
4272     + cmds.buf, cmd_size, &cmd_rc);
4273     + if (rc < 0 || cmd_rc) {
4274     + dev_dbg(dev, "%s: failed at: %d rc: %d cmd_rc: %d\n",
4275     + __func__, __LINE__, rc, cmd_rc);
4276     + return -EIO;
4277     + }
4278     +
4279     return 0;
4280     }
4281    
4282     diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh
4283     index 57b5ff576240..891130daac7c 100755
4284     --- a/tools/testing/selftests/net/rtnetlink.sh
4285     +++ b/tools/testing/selftests/net/rtnetlink.sh
4286     @@ -1,4 +1,4 @@
4287     -#!/bin/sh
4288     +#!/bin/bash
4289     #
4290     # This test is for checking rtnetlink callpaths, and get as much coverage as possible.
4291     #
4292     diff --git a/tools/testing/selftests/powerpc/ptrace/.gitignore b/tools/testing/selftests/powerpc/ptrace/.gitignore
4293     index 349acfafc95b..9dcc16ea8179 100644
4294     --- a/tools/testing/selftests/powerpc/ptrace/.gitignore
4295     +++ b/tools/testing/selftests/powerpc/ptrace/.gitignore
4296     @@ -8,3 +8,4 @@ ptrace-vsx
4297     ptrace-tm-vsx
4298     ptrace-tm-spd-vsx
4299     ptrace-tm-spr
4300     +ptrace-hwbreak
4301     diff --git a/tools/testing/selftests/powerpc/ptrace/Makefile b/tools/testing/selftests/powerpc/ptrace/Makefile
4302     index 480305266504..0e2f4601d1a8 100644
4303     --- a/tools/testing/selftests/powerpc/ptrace/Makefile
4304     +++ b/tools/testing/selftests/powerpc/ptrace/Makefile
4305     @@ -1,7 +1,7 @@
4306     # SPDX-License-Identifier: GPL-2.0
4307     TEST_PROGS := ptrace-gpr ptrace-tm-gpr ptrace-tm-spd-gpr \
4308     ptrace-tar ptrace-tm-tar ptrace-tm-spd-tar ptrace-vsx ptrace-tm-vsx \
4309     - ptrace-tm-spd-vsx ptrace-tm-spr
4310     + ptrace-tm-spd-vsx ptrace-tm-spr ptrace-hwbreak
4311    
4312     include ../../lib.mk
4313    
4314     diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c b/tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c
4315     new file mode 100644
4316     index 000000000000..3066d310f32b
4317     --- /dev/null
4318     +++ b/tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c
4319     @@ -0,0 +1,342 @@
4320     +// SPDX-License-Identifier: GPL-2.0+
4321     +
4322     +/*
4323     + * Ptrace test for hw breakpoints
4324     + *
4325     + * Based on tools/testing/selftests/breakpoints/breakpoint_test.c
4326     + *
4327     + * This test forks and the parent then traces the child doing various
4328     + * types of ptrace enabled breakpoints
4329     + *
4330     + * Copyright (C) 2018 Michael Neuling, IBM Corporation.
4331     + */
4332     +
4333     +#include <sys/ptrace.h>
4334     +#include <unistd.h>
4335     +#include <stddef.h>
4336     +#include <sys/user.h>
4337     +#include <stdio.h>
4338     +#include <stdlib.h>
4339     +#include <signal.h>
4340     +#include <sys/types.h>
4341     +#include <sys/wait.h>
4342     +#include "ptrace.h"
4343     +
4344     +/* Breakpoint access modes */
4345     +enum {
4346     + BP_X = 1,
4347     + BP_RW = 2,
4348     + BP_W = 4,
4349     +};
4350     +
4351     +static pid_t child_pid;
4352     +static struct ppc_debug_info dbginfo;
4353     +
4354     +static void get_dbginfo(void)
4355     +{
4356     + int ret;
4357     +
4358     + ret = ptrace(PPC_PTRACE_GETHWDBGINFO, child_pid, NULL, &dbginfo);
4359     + if (ret) {
4360     + perror("Can't get breakpoint info\n");
4361     + exit(-1);
4362     + }
4363     +}
4364     +
4365     +static bool hwbreak_present(void)
4366     +{
4367     + return (dbginfo.num_data_bps != 0);
4368     +}
4369     +
4370     +static bool dawr_present(void)
4371     +{
4372     + return !!(dbginfo.features & PPC_DEBUG_FEATURE_DATA_BP_DAWR);
4373     +}
4374     +
4375     +static void set_breakpoint_addr(void *addr)
4376     +{
4377     + int ret;
4378     +
4379     + ret = ptrace(PTRACE_SET_DEBUGREG, child_pid, 0, addr);
4380     + if (ret) {
4381     + perror("Can't set breakpoint addr\n");
4382     + exit(-1);
4383     + }
4384     +}
4385     +
4386     +static int set_hwbreakpoint_addr(void *addr, int range)
4387     +{
4388     + int ret;
4389     +
4390     + struct ppc_hw_breakpoint info;
4391     +
4392     + info.version = 1;
4393     + info.trigger_type = PPC_BREAKPOINT_TRIGGER_RW;
4394     + info.addr_mode = PPC_BREAKPOINT_MODE_EXACT;
4395     + if (range > 0)
4396     + info.addr_mode = PPC_BREAKPOINT_MODE_RANGE_INCLUSIVE;
4397     + info.condition_mode = PPC_BREAKPOINT_CONDITION_NONE;
4398     + info.addr = (__u64)addr;
4399     + info.addr2 = (__u64)addr + range;
4400     + info.condition_value = 0;
4401     +
4402     + ret = ptrace(PPC_PTRACE_SETHWDEBUG, child_pid, 0, &info);
4403     + if (ret < 0) {
4404     + perror("Can't set breakpoint\n");
4405     + exit(-1);
4406     + }
4407     + return ret;
4408     +}
4409     +
4410     +static int del_hwbreakpoint_addr(int watchpoint_handle)
4411     +{
4412     + int ret;
4413     +
4414     + ret = ptrace(PPC_PTRACE_DELHWDEBUG, child_pid, 0, watchpoint_handle);
4415     + if (ret < 0) {
4416     + perror("Can't delete hw breakpoint\n");
4417     + exit(-1);
4418     + }
4419     + return ret;
4420     +}
4421     +
4422     +#define DAWR_LENGTH_MAX 512
4423     +
4424     +/* Dummy variables to test read/write accesses */
4425     +static unsigned long long
4426     + dummy_array[DAWR_LENGTH_MAX / sizeof(unsigned long long)]
4427     + __attribute__((aligned(512)));
4428     +static unsigned long long *dummy_var = dummy_array;
4429     +
4430     +static void write_var(int len)
4431     +{
4432     + long long *plval;
4433     + char *pcval;
4434     + short *psval;
4435     + int *pival;
4436     +
4437     + switch (len) {
4438     + case 1:
4439     + pcval = (char *)dummy_var;
4440     + *pcval = 0xff;
4441     + break;
4442     + case 2:
4443     + psval = (short *)dummy_var;
4444     + *psval = 0xffff;
4445     + break;
4446     + case 4:
4447     + pival = (int *)dummy_var;
4448     + *pival = 0xffffffff;
4449     + break;
4450     + case 8:
4451     + plval = (long long *)dummy_var;
4452     + *plval = 0xffffffffffffffffLL;
4453     + break;
4454     + }
4455     +}
4456     +
4457     +static void read_var(int len)
4458     +{
4459     + char cval __attribute__((unused));
4460     + short sval __attribute__((unused));
4461     + int ival __attribute__((unused));
4462     + long long lval __attribute__((unused));
4463     +
4464     + switch (len) {
4465     + case 1:
4466     + cval = *(char *)dummy_var;
4467     + break;
4468     + case 2:
4469     + sval = *(short *)dummy_var;
4470     + break;
4471     + case 4:
4472     + ival = *(int *)dummy_var;
4473     + break;
4474     + case 8:
4475     + lval = *(long long *)dummy_var;
4476     + break;
4477     + }
4478     +}
4479     +
4480     +/*
4481     + * Do the r/w accesses to trigger the breakpoints. And run
4482     + * the usual traps.
4483     + */
4484     +static void trigger_tests(void)
4485     +{
4486     + int len, ret;
4487     +
4488     + ret = ptrace(PTRACE_TRACEME, 0, NULL, 0);
4489     + if (ret) {
4490     + perror("Can't be traced?\n");
4491     + return;
4492     + }
4493     +
4494     + /* Wake up father so that it sets up the first test */
4495     + kill(getpid(), SIGUSR1);
4496     +
4497     + /* Test write watchpoints */
4498     + for (len = 1; len <= sizeof(long); len <<= 1)
4499     + write_var(len);
4500     +
4501     + /* Test read/write watchpoints (on read accesses) */
4502     + for (len = 1; len <= sizeof(long); len <<= 1)
4503     + read_var(len);
4504     +
4505     + /* Test when breakpoint is unset */
4506     +
4507     + /* Test write watchpoints */
4508     + for (len = 1; len <= sizeof(long); len <<= 1)
4509     + write_var(len);
4510     +
4511     + /* Test read/write watchpoints (on read accesses) */
4512     + for (len = 1; len <= sizeof(long); len <<= 1)
4513     + read_var(len);
4514     +}
4515     +
4516     +static void check_success(const char *msg)
4517     +{
4518     + const char *msg2;
4519     + int status;
4520     +
4521     + /* Wait for the child to SIGTRAP */
4522     + wait(&status);
4523     +
4524     + msg2 = "Failed";
4525     +
4526     + if (WIFSTOPPED(status) && WSTOPSIG(status) == SIGTRAP) {
4527     + msg2 = "Child process hit the breakpoint";
4528     + }
4529     +
4530     + printf("%s Result: [%s]\n", msg, msg2);
4531     +}
4532     +
4533     +static void launch_watchpoints(char *buf, int mode, int len,
4534     + struct ppc_debug_info *dbginfo, bool dawr)
4535     +{
4536     + const char *mode_str;
4537     + unsigned long data = (unsigned long)(dummy_var);
4538     + int wh, range;
4539     +
4540     + data &= ~0x7UL;
4541     +
4542     + if (mode == BP_W) {
4543     + data |= (1UL << 1);
4544     + mode_str = "write";
4545     + } else {
4546     + data |= (1UL << 0);
4547     + data |= (1UL << 1);
4548     + mode_str = "read";
4549     + }
4550     +
4551     + /* Set DABR_TRANSLATION bit */
4552     + data |= (1UL << 2);
4553     +
4554     + /* use PTRACE_SET_DEBUGREG breakpoints */
4555     + set_breakpoint_addr((void *)data);
4556     + ptrace(PTRACE_CONT, child_pid, NULL, 0);
4557     + sprintf(buf, "Test %s watchpoint with len: %d ", mode_str, len);
4558     + check_success(buf);
4559     + /* Unregister hw brkpoint */
4560     + set_breakpoint_addr(NULL);
4561     +
4562     + data = (data & ~7); /* remove dabr control bits */
4563     +
4564     + /* use PPC_PTRACE_SETHWDEBUG breakpoint */
4565     + if (!(dbginfo->features & PPC_DEBUG_FEATURE_DATA_BP_RANGE))
4566     + return; /* not supported */
4567     + wh = set_hwbreakpoint_addr((void *)data, 0);
4568     + ptrace(PTRACE_CONT, child_pid, NULL, 0);
4569     + sprintf(buf, "Test %s watchpoint with len: %d ", mode_str, len);
4570     + check_success(buf);
4571     + /* Unregister hw brkpoint */
4572     + del_hwbreakpoint_addr(wh);
4573     +
4574     + /* try a wider range */
4575     + range = 8;
4576     + if (dawr)
4577     + range = 512 - ((int)data & (DAWR_LENGTH_MAX - 1));
4578     + wh = set_hwbreakpoint_addr((void *)data, range);
4579     + ptrace(PTRACE_CONT, child_pid, NULL, 0);
4580     + sprintf(buf, "Test %s watchpoint with len: %d ", mode_str, len);
4581     + check_success(buf);
4582     + /* Unregister hw brkpoint */
4583     + del_hwbreakpoint_addr(wh);
4584     +}
4585     +
4586     +/* Set the breakpoints and check the child successfully trigger them */
4587     +static int launch_tests(bool dawr)
4588     +{
4589     + char buf[1024];
4590     + int len, i, status;
4591     +
4592     + struct ppc_debug_info dbginfo;
4593     +
4594     + i = ptrace(PPC_PTRACE_GETHWDBGINFO, child_pid, NULL, &dbginfo);
4595     + if (i) {
4596     + perror("Can't set breakpoint info\n");
4597     + exit(-1);
4598     + }
4599     + if (!(dbginfo.features & PPC_DEBUG_FEATURE_DATA_BP_RANGE))
4600     + printf("WARNING: Kernel doesn't support PPC_PTRACE_SETHWDEBUG\n");
4601     +
4602     + /* Write watchpoint */
4603     + for (len = 1; len <= sizeof(long); len <<= 1)
4604     + launch_watchpoints(buf, BP_W, len, &dbginfo, dawr);
4605     +
4606     + /* Read-Write watchpoint */
4607     + for (len = 1; len <= sizeof(long); len <<= 1)
4608     + launch_watchpoints(buf, BP_RW, len, &dbginfo, dawr);
4609     +
4610     + ptrace(PTRACE_CONT, child_pid, NULL, 0);
4611     +
4612     + /*
4613     + * Now we have unregistered the breakpoint, access by child
4614     + * should not cause SIGTRAP.
4615     + */
4616     +
4617     + wait(&status);
4618     +
4619     + if (WIFSTOPPED(status) && WSTOPSIG(status) == SIGTRAP) {
4620     + printf("FAIL: Child process hit the breakpoint, which is not expected\n");
4621     + ptrace(PTRACE_CONT, child_pid, NULL, 0);
4622     + return TEST_FAIL;
4623     + }
4624     +
4625     + if (WIFEXITED(status))
4626     + printf("Child exited normally\n");
4627     +
4628     + return TEST_PASS;
4629     +}
4630     +
4631     +static int ptrace_hwbreak(void)
4632     +{
4633     + pid_t pid;
4634     + int ret;
4635     + bool dawr;
4636     +
4637     + pid = fork();
4638     + if (!pid) {
4639     + trigger_tests();
4640     + return 0;
4641     + }
4642     +
4643     + wait(NULL);
4644     +
4645     + child_pid = pid;
4646     +
4647     + get_dbginfo();
4648     + SKIP_IF(!hwbreak_present());
4649     + dawr = dawr_present();
4650     +
4651     + ret = launch_tests(dawr);
4652     +
4653     + wait(NULL);
4654     +
4655     + return ret;
4656     +}
4657     +
4658     +int main(int argc, char **argv, char **envp)
4659     +{
4660     + return test_harness(ptrace_hwbreak, "ptrace-hwbreak");
4661     +}